Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danbryce committed Jan 29, 2024
1 parent a80c4ec commit 97663f2
Show file tree
Hide file tree
Showing 16 changed files with 3,010 additions and 3,825 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def animate(i):
ax = sns.heatmap(data, vmin=vmin, vmax=vmax, cmap="crest")
ax.set_xlabel(data.columns[0][0])
ax.set_ylabel(data.index.name)
ax.set_title(data.columns[0][0])
ax.set_title(f"{data.columns[0][0]}: time = {i}")

anim = animation.FuncAnimation(
fig,
Expand Down
Binary file added docs/source/_static/advection_backward_2D.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/halfar_backward_1D.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/halfar_centered_1D.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/halfar_forward_1D.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions docs/source/use_cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,32 @@ Climate Use Cases
.. _pde as petri: https://github.com/ml4ai/funman/tree/main/notebooks/pde_as_petrinet.ipynb
.. _pde to petri translation: https://github.com/ml4ai/funman/tree/main/auxiliary_packages/pde2petri/doc/discretization/main.pdf
.. _advection: https://www.uni-muenster.de/imperia/md/content/physik_tp/lectures/ws2016-2017/num_methods_i/advection.pdf
.. _model representation: https://github.com/DARPA-ASKEM/Model-Representations/pull/77

We developed use cases for climate models by translating the climate models into petri nets. The use cases involve both consistency and parameter synthesis problems. The notebook `pde to petri`_ demonstrates scenarios for the Halfar ice dome and advection models. The methodology for translating the PDE models into petri nets is described in the `pde to petri translation`_ documentation.

Identify Parameters for Halfar Ice Model
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We developed two formulations of the Halfar Ice dome model that used one-sided or centered differential expressions to compare alternative discretization strategies. We found that the centered differential expressions are able to model the ice dome change symmetrically and the one-sided differentials led to asymmetric change. This motivates the use of FUNMAN to investigate the stability of different discretization schemes.
We developed multiple formulations of the Halfar Ice dome model that used different differential expressions to compare alternative discretization strategies. Each model uses a parameter A, which FUNMAN selects to ensure that the ice cap height at each discretized location remained non-negative. We found that if given the range [1e-20, 1e-12] for the A parameter, FUNMAN is capable of finding a value for A that prevents the ice height from becoming negative. We also found several differences between the difference methods used to discretize the PDE, namely that centered difference produces symmetric change in the ice dome, and backward and forward difference do not.

.. The centered difference:
.. .. image:: _static/halfar_centered_1D.gif
.. The forward difference:
.. .. image:: _static/halfar_forward_1D.gif
.. The backward difference:
.. .. image:: _static/halfar_backward_1D.gif
Compare Discretization Methods for PDEs with the Advection Model
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In the case of the Advection Equation, we are able to observe phenomena that is expected from the literature [`advection`_]. For example, for the equation ∂h/∂t + a * ∂h/∂x = 0 where a > 0, we expect different results depending on the choice of discretization. Since both the solution and stability behavior is known, our next steps will be to validate FUNMAN’s parameter synthesis by comparing FUNMAN’s calculated valid parameter ranges for the advection equation to what is known in the literature in the forward, centered, and backward difference scheme cases. FUNMAN was able discover how the forward difference scheme violates the non-negativity constraints we placed upon the model, and that the backward scheme does not.

The following figure (gif) animates a time series computed by FUNMAN for the two dimensional advection equation where the boundary condition is zero for all locations and times. The initial state models a dome-like energy variable “a” over a 5x5 grid. FUNMAN identifies a parameter value “u” that satisfies several constraints. The constraints are that “u” is in [0.5, 1], and that “a” is non-negative for all time steps and locations. FUNMAN solves this problem with a petri net encoding of the discretized PDE, using a backward derivative for the spatial dimensions and a forward derivative for the temporal dimension. The solution animated below assigns u = 0.5 and corresponds to a positive velocity that moves the energy in the positive direction in each dimension and diffusion. The AMR for this instance is available through the ASKEM Model-Representation repo.
The following figure (gif) animates a time series computed by FUNMAN for the two dimensional advection equation where the boundary condition is zero for all locations and times. The initial state models a dome-like energy variable “a” over a 5x5 grid. FUNMAN identifies a parameter value “u” that satisfies several constraints. The constraints are that “u” is in [0.5, 1], and that “a” is non-negative for all time steps and locations. FUNMAN solves this problem with a petri net encoding of the discretized PDE, using a backward derivative for the spatial dimensions and a forward derivative for the temporal dimension. The solution animated below assigns u = 0.5 and corresponds to a positive velocity that moves the energy in the positive direction in each dimension and diffusion. The AMR for this instance is available through the ASKEM `model representation`_ repo.

.. image:: _static/advection_backward_2D.gif
Binary file added fig/advection_backward_2D.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6,786 changes: 2,978 additions & 3,808 deletions notebooks/pde_as_petrinet.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/funman/scenario/consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConsistencyScenario(AnalysisScenario, BaseModel):
Parameters
----------
model : Model
model : FunmanModel
model to check
query : Query
model query
Expand Down
2 changes: 1 addition & 1 deletion src/funman/translate/bilayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def encode_model(
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down
2 changes: 1 addition & 1 deletion src/funman/translate/decapode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def encode_model(self, scenario: "AnalysisScenario") -> Encoding:
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down
2 changes: 1 addition & 1 deletion src/funman/translate/encoded.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def encode_model(self, model: FunmanModel):
Parameters
----------
model : Model
model : FunmanModel
Encoded model
Returns
Expand Down
4 changes: 2 additions & 2 deletions src/funman/translate/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def encode_model(self, scenario: "AnalysisScenario") -> Encoding:
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down Expand Up @@ -91,7 +91,7 @@ def _get_timed_symbols(self, model: FunmanModel) -> Set[str]:
Parameters
----------
model : Model
model : FunmanModel
The petrinet model
Returns
Expand Down
4 changes: 2 additions & 2 deletions src/funman/translate/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def encode_model(self, model: "FunmanModel") -> Encoding:
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down Expand Up @@ -376,7 +376,7 @@ def _get_timed_symbols(self, model: FunmanModel) -> Set[str]:
Parameters
----------
model : Model
model : FunmanModel
The petrinet model
Returns
Expand Down
4 changes: 2 additions & 2 deletions src/funman/translate/regnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def encode_model(self, model: "FunmanModel") -> Encoding:
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down Expand Up @@ -115,7 +115,7 @@ def _get_timed_symbols(self, model: FunmanModel) -> Set[str]:
Parameters
----------
model : Model
model : FunmanModel
The regnet model
Returns
Expand Down
8 changes: 4 additions & 4 deletions src/funman/translate/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def encode_model_timed(
Parameters
----------
model : Model
model : FunmanModel
model to encode
num_steps: int
number of encoding steps (e.g., time steps)
Expand Down Expand Up @@ -522,7 +522,7 @@ def _get_timed_symbols(self, model: FunmanModel) -> Set[str]:
Parameters
----------
model : Model
model : FunmanModel
The petrinet model
Returns
Expand Down Expand Up @@ -933,7 +933,7 @@ def encode_query_layer(
Parameters
----------
model : Model
model : FunmanModel
model to encode
Returns
Expand Down Expand Up @@ -1193,7 +1193,7 @@ def interval_to_smt(
Parameters
----------
p : Parameter
p : funman.representation.parameter.Parameter
parameter to constrain
closed_upper_bound : bool, optional
interpret interval as closed (i.e., p <= ub), by default False
Expand Down

0 comments on commit 97663f2

Please sign in to comment.