Update Condition notation & domains import in tutorials
This commit is contained in:
14
tutorials/tutorial11/tutorial.ipynb
vendored
14
tutorials/tutorial11/tutorial.ipynb
vendored
@@ -39,7 +39,7 @@
|
||||
"from pina.model import FeedForward\n",
|
||||
"from pina.problem import SpatialProblem\n",
|
||||
"from pina.operators import grad\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"from pina.equation import Equation, FixedValue\n",
|
||||
"\n",
|
||||
"class SimpleODE(SpatialProblem):\n",
|
||||
@@ -55,8 +55,8 @@
|
||||
"\n",
|
||||
" # conditions to hold\n",
|
||||
" conditions = {\n",
|
||||
" 'x0': Condition(location=CartesianDomain({'x': 0.}), equation=FixedValue(1)), # We fix initial condition to value 1\n",
|
||||
" 'D': Condition(location=CartesianDomain({'x': [0, 1]}), equation=Equation(ode_equation)), # We wrap the python equation using Equation\n",
|
||||
" 'bound_cond': Condition(domain=CartesianDomain({'x': 0.}), equation=FixedValue(1)), # We fix initial condition to value 1\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1]}), equation=Equation(ode_equation)), # We wrap the python equation using Equation\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" # defining the true solution\n",
|
||||
@@ -66,8 +66,8 @@
|
||||
"\n",
|
||||
"# sampling for training\n",
|
||||
"problem = SimpleODE()\n",
|
||||
"problem.discretise_domain(1, 'random', locations=['x0'])\n",
|
||||
"problem.discretise_domain(20, 'lh', locations=['D'])\n",
|
||||
"problem.discretise_domain(1, 'random', domains=['bound_cond'])\n",
|
||||
"problem.discretise_domain(20, 'lh', domains=['phys_cond'])\n",
|
||||
"\n",
|
||||
"# build the model\n",
|
||||
"model = FeedForward(\n",
|
||||
@@ -809,7 +809,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "pina",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -823,7 +823,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
8
tutorials/tutorial11/tutorial.py
vendored
8
tutorials/tutorial11/tutorial.py
vendored
@@ -48,8 +48,8 @@ class SimpleODE(SpatialProblem):
|
||||
|
||||
# conditions to hold
|
||||
conditions = {
|
||||
'x0': Condition(location=CartesianDomain({'x': 0.}), equation=FixedValue(1)), # We fix initial condition to value 1
|
||||
'D': Condition(location=CartesianDomain({'x': [0, 1]}), equation=Equation(ode_equation)), # We wrap the python equation using Equation
|
||||
'bound_cond': Condition(domain=CartesianDomain({'x': 0.}), equation=FixedValue(1)), # We fix initial condition to value 1
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1]}), equation=Equation(ode_equation)), # We wrap the python equation using Equation
|
||||
}
|
||||
|
||||
# defining the true solution
|
||||
@@ -59,8 +59,8 @@ class SimpleODE(SpatialProblem):
|
||||
|
||||
# sampling for training
|
||||
problem = SimpleODE()
|
||||
problem.discretise_domain(1, 'random', locations=['x0'])
|
||||
problem.discretise_domain(20, 'lh', locations=['D'])
|
||||
problem.discretise_domain(1, 'random', domains=['bound_cond'])
|
||||
problem.discretise_domain(20, 'lh', domains=['phys_cond'])
|
||||
|
||||
# build the model
|
||||
model = FeedForward(
|
||||
|
||||
16
tutorials/tutorial12/tutorial.ipynb
vendored
16
tutorials/tutorial12/tutorial.ipynb
vendored
@@ -100,10 +100,10 @@
|
||||
"\n",
|
||||
" # problem condition statement\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 't0': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'D': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Equation(burger_equation)),\n",
|
||||
" 'bound_cond1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'time_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Equation(burger_equation)),\n",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
@@ -196,10 +196,10 @@
|
||||
"\n",
|
||||
" # problem condition statement\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 't0': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'D': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Burgers1DEquation(0.01/torch.pi)),\n",
|
||||
" 'bound_cond1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'time_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Burgers1DEquation(0.01/torch.pi)),\n",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
|
||||
35
tutorials/tutorial12/tutorial.py
vendored
35
tutorials/tutorial12/tutorial.py
vendored
@@ -26,7 +26,7 @@
|
||||
#
|
||||
# In the class that models this problem we will see in action the `Equation` class and one of its inherited classes, the `FixedValue` class.
|
||||
|
||||
# In[7]:
|
||||
# In[1]:
|
||||
|
||||
|
||||
## routine needed to run the notebook on Google Colab
|
||||
@@ -40,14 +40,15 @@ if IN_COLAB:
|
||||
|
||||
#useful imports
|
||||
from pina.problem import SpatialProblem, TimeDependentProblem
|
||||
from pina.equation import Equation, FixedValue, FixedGradient, FixedFlux
|
||||
from pina.equation import Equation, FixedValue
|
||||
from pina.domain import CartesianDomain
|
||||
import torch
|
||||
from pina.operators import grad, laplacian
|
||||
from pina import Condition
|
||||
|
||||
|
||||
# In[6]:
|
||||
|
||||
# In[2]:
|
||||
|
||||
|
||||
class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
@@ -74,17 +75,17 @@ class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
|
||||
# problem condition statement
|
||||
conditions = {
|
||||
'gamma1': Condition(location=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma2': Condition(location=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
't0': Condition(location=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'D': Condition(location=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Equation(burger_equation)),
|
||||
'bound_cond1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'time_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Equation(burger_equation)),
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# The `Equation` class takes as input a function (in this case it happens twice, with `initial_condition` and `burger_equation`) which computes a residual of an equation, such as a PDE. In a problem class such as the one above, the `Equation` class with such a given input is passed as a parameter in the specified `Condition`.
|
||||
#
|
||||
# The `FixedValue` class takes as input a value of same dimensions of the output functions; this class can be used to enforced a fixed value for a specific condition, e.g. Dirichlet boundary conditions, as it happens for instance in our example.
|
||||
# The `FixedValue` class takes as input a value of same dimensions of the output functions; this class can be used to enforce a fixed value for a specific condition, e.g. Dirichlet boundary conditions, as it happens for instance in our example.
|
||||
#
|
||||
# Once the equations are set as above in the problem conditions, the PINN solver will aim to minimize the residuals described in each equation in the training phase.
|
||||
|
||||
@@ -98,7 +99,7 @@ class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
|
||||
# `Equation` classes can be also inherited to define a new class. As example, we can see how to rewrite the above problem introducing a new class `Burgers1D`; during the class call, we can pass the viscosity parameter $\nu$:
|
||||
|
||||
# In[13]:
|
||||
# In[3]:
|
||||
|
||||
|
||||
class Burgers1DEquation(Equation):
|
||||
@@ -113,7 +114,9 @@ class Burgers1DEquation(Equation):
|
||||
self.nu = nu
|
||||
|
||||
def equation(input_, output_):
|
||||
return grad(output_, input_, d='t') + output_*grad(output_, input_, d='x') - self.nu*laplacian(output_, input_, d='x')
|
||||
return grad(output_, input_, d='t') +\
|
||||
output_*grad(output_, input_, d='x') -\
|
||||
self.nu*laplacian(output_, input_, d='x')
|
||||
|
||||
|
||||
super().__init__(equation)
|
||||
@@ -121,7 +124,7 @@ class Burgers1DEquation(Equation):
|
||||
|
||||
# Now we can just pass the above class as input for the last condition, setting $\nu= \frac{0.01}{\pi}$:
|
||||
|
||||
# In[14]:
|
||||
# In[4]:
|
||||
|
||||
|
||||
class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
@@ -138,16 +141,16 @@ class Burgers1D(TimeDependentProblem, SpatialProblem):
|
||||
|
||||
# problem condition statement
|
||||
conditions = {
|
||||
'gamma1': Condition(location=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma2': Condition(location=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
't0': Condition(location=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'D': Condition(location=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Burgers1DEquation(0.01/torch.pi)),
|
||||
'bound_cond1': Condition(domain=CartesianDomain({'x': -1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond2': Condition(domain=CartesianDomain({'x': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'time_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [-1, 1], 't': [0, 1]}), equation=Burgers1DEquation(0.01/torch.pi)),
|
||||
}
|
||||
|
||||
|
||||
# # What's next?
|
||||
|
||||
# Congratulations on completing the `Equation` class tutorial of **PINA**! As we have seen, you can build new classes that inherits `Equation` to store more complex equations, as the Burgers 1D equation, only requiring to pass the characteristic coefficients of the problem.
|
||||
# Congratulations on completing the `Equation` class tutorial of **PINA**! As we have seen, you can build new classes that inherit `Equation` to store more complex equations, as the Burgers 1D equation, only requiring to pass the characteristic coefficients of the problem.
|
||||
# From now on, you can:
|
||||
# - define additional complex equation classes (e.g. `SchrodingerEquation`, `NavierStokeEquation`..)
|
||||
# - define more `FixedOperator` (e.g. `FixedCurl`)
|
||||
|
||||
12
tutorials/tutorial13/tutorial.ipynb
vendored
12
tutorials/tutorial13/tutorial.ipynb
vendored
@@ -40,7 +40,7 @@
|
||||
"from pina.solvers import PINN, SAPINN\n",
|
||||
"from pina.model.layers import FourierFeatureEmbedding\n",
|
||||
"from pina.loss import LpLoss\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"from pina.equation import Equation, FixedValue\n",
|
||||
"from pina.model import FeedForward\n"
|
||||
]
|
||||
@@ -89,11 +89,11 @@
|
||||
"\n",
|
||||
" # here we write the problem conditions\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma0' : Condition(location=CartesianDomain({'x': 0}),\n",
|
||||
" 'bound_cond0' : Condition(domain=CartesianDomain({'x': 0}),\n",
|
||||
" equation=FixedValue(0)),\n",
|
||||
" 'gamma1' : Condition(location=CartesianDomain({'x': 1}),\n",
|
||||
" 'bound_cond1' : Condition(domain=CartesianDomain({'x': 1}),\n",
|
||||
" equation=FixedValue(0)),\n",
|
||||
" 'D': Condition(location=spatial_domain,\n",
|
||||
" 'phys_cond': Condition(domain=spatial_domain,\n",
|
||||
" equation=Equation(poisson_equation)),\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
@@ -453,7 +453,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "pina",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -467,7 +467,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
8
tutorials/tutorial13/tutorial.py
vendored
8
tutorials/tutorial13/tutorial.py
vendored
@@ -33,7 +33,7 @@ from pina.operators import laplacian
|
||||
from pina.solvers import PINN, SAPINN
|
||||
from pina.model.layers import FourierFeatureEmbedding
|
||||
from pina.loss import LpLoss
|
||||
from pina.geometry import CartesianDomain
|
||||
from pina.domain import CartesianDomain
|
||||
from pina.equation import Equation, FixedValue
|
||||
from pina.model import FeedForward
|
||||
|
||||
@@ -74,11 +74,11 @@ class Poisson(SpatialProblem):
|
||||
|
||||
# here we write the problem conditions
|
||||
conditions = {
|
||||
'gamma0' : Condition(location=CartesianDomain({'x': 0}),
|
||||
'bound_cond0' : Condition(domain=CartesianDomain({'x': 0}),
|
||||
equation=FixedValue(0)),
|
||||
'gamma1' : Condition(location=CartesianDomain({'x': 1}),
|
||||
'bound_cond1' : Condition(domain=CartesianDomain({'x': 1}),
|
||||
equation=FixedValue(0)),
|
||||
'D': Condition(location=spatial_domain,
|
||||
'phys_cond': Condition(domain=spatial_domain,
|
||||
equation=Equation(poisson_equation)),
|
||||
}
|
||||
|
||||
|
||||
23
tutorials/tutorial2/tutorial.ipynb
vendored
23
tutorials/tutorial2/tutorial.ipynb
vendored
@@ -39,7 +39,7 @@
|
||||
"from pina.solvers import PINN\n",
|
||||
"from pina.trainer import Trainer\n",
|
||||
"from pina.plotter import Plotter\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"from pina.equation import Equation, FixedValue\n",
|
||||
"from pina import Condition, LabelTensor\n",
|
||||
"from pina.callbacks import MetricTracker"
|
||||
@@ -90,11 +90,11 @@
|
||||
"\n",
|
||||
" # here we write the problem conditions\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma1': Condition(location=CartesianDomain({'x': [0, 1], 'y': 1}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma2': Condition(location=CartesianDomain({'x': [0, 1], 'y': 0}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma3': Condition(location=CartesianDomain({'x': 1, 'y': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma4': Condition(location=CartesianDomain({'x': 0, 'y': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'D': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1]}), equation=Equation(laplace_equation)),\n",
|
||||
" 'bound_cond1': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 1}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond2': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 0}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond3': Condition(domain=CartesianDomain({'x': 1, 'y': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond4': Condition(domain=CartesianDomain({'x': 0, 'y': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1]}), equation=Equation(laplace_equation)),\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" def poisson_sol(self, pts):\n",
|
||||
@@ -108,8 +108,8 @@
|
||||
"problem = Poisson()\n",
|
||||
"\n",
|
||||
"# let's discretise the domain\n",
|
||||
"problem.discretise_domain(25, 'grid', locations=['D'])\n",
|
||||
"problem.discretise_domain(25, 'grid', locations=['gamma1', 'gamma2', 'gamma3', 'gamma4'])"
|
||||
"problem.discretise_domain(25, 'grid', domains=['phys_cond'])\n",
|
||||
"problem.discretise_domain(25, 'grid', domains=['bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -585,11 +585,8 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "56be7540488f3dc66429ddf54a0fa9de50124d45fcfccfaf04c4c3886d735a3a"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -603,7 +600,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
14
tutorials/tutorial2/tutorial.py
vendored
14
tutorials/tutorial2/tutorial.py
vendored
@@ -65,11 +65,11 @@ class Poisson(SpatialProblem):
|
||||
|
||||
# here we write the problem conditions
|
||||
conditions = {
|
||||
'gamma1': Condition(location=CartesianDomain({'x': [0, 1], 'y': 1}), equation=FixedValue(0.)),
|
||||
'gamma2': Condition(location=CartesianDomain({'x': [0, 1], 'y': 0}), equation=FixedValue(0.)),
|
||||
'gamma3': Condition(location=CartesianDomain({'x': 1, 'y': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma4': Condition(location=CartesianDomain({'x': 0, 'y': [0, 1]}), equation=FixedValue(0.)),
|
||||
'D': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1]}), equation=Equation(laplace_equation)),
|
||||
'bound_cond1': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 1}), equation=FixedValue(0.)),
|
||||
'bound_cond2': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 0}), equation=FixedValue(0.)),
|
||||
'bound_cond3': Condition(domain=CartesianDomain({'x': 1, 'y': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond4': Condition(domain=CartesianDomain({'x': 0, 'y': [0, 1]}), equation=FixedValue(0.)),
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1]}), equation=Equation(laplace_equation)),
|
||||
}
|
||||
|
||||
def poisson_sol(self, pts):
|
||||
@@ -83,8 +83,8 @@ class Poisson(SpatialProblem):
|
||||
problem = Poisson()
|
||||
|
||||
# let's discretise the domain
|
||||
problem.discretise_domain(25, 'grid', locations=['D'])
|
||||
problem.discretise_domain(25, 'grid', locations=['gamma1', 'gamma2', 'gamma3', 'gamma4'])
|
||||
problem.discretise_domain(25, 'grid', locations=['phys_cond'])
|
||||
problem.discretise_domain(25, 'grid', locations=['bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])
|
||||
|
||||
|
||||
# ## Solving the problem with standard PINNs
|
||||
|
||||
25
tutorials/tutorial3/tutorial.ipynb
vendored
25
tutorials/tutorial3/tutorial.ipynb
vendored
@@ -34,7 +34,7 @@
|
||||
"\n",
|
||||
"from pina.problem import SpatialProblem, TimeDependentProblem\n",
|
||||
"from pina.operators import laplacian, grad\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"from pina.solvers import PINN\n",
|
||||
"from pina.trainer import Trainer\n",
|
||||
"from pina.equation import Equation\n",
|
||||
@@ -100,12 +100,12 @@
|
||||
" return output_.extract(['u']) - u_expected\n",
|
||||
"\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma1': Condition(location=CartesianDomain({'x': [0, 1], 'y': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma2': Condition(location=CartesianDomain({'x': [0, 1], 'y': 0, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma3': Condition(location=CartesianDomain({'x': 1, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'gamma4': Condition(location=CartesianDomain({'x': 0, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 't0': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'D': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': [0, 1]}), equation=Equation(wave_equation)),\n",
|
||||
" 'bound_cond1': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 1, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond2': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 0, 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond3': Condition(domain=CartesianDomain({'x': 1, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'bound_cond4': Condition(domain=CartesianDomain({'x': 0, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),\n",
|
||||
" 'time_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': 0}), equation=Equation(initial_condition)),\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': [0, 1]}), equation=Equation(wave_equation)),\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" def wave_sol(self, pts):\n",
|
||||
@@ -219,7 +219,7 @@
|
||||
],
|
||||
"source": [
|
||||
"# generate the data\n",
|
||||
"problem.discretise_domain(1000, 'random', locations=['D', 't0', 'gamma1', 'gamma2', 'gamma3', 'gamma4'])\n",
|
||||
"problem.discretise_domain(1000, 'random', domains=['phys_cond', 'time_cond', 'bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])\n",
|
||||
"\n",
|
||||
"# crete the solver\n",
|
||||
"pinn = PINN(problem, HardMLP(len(problem.input_variables), len(problem.output_variables)))\n",
|
||||
@@ -405,7 +405,7 @@
|
||||
],
|
||||
"source": [
|
||||
"# generate the data\n",
|
||||
"problem.discretise_domain(1000, 'random', locations=['D', 't0', 'gamma1', 'gamma2', 'gamma3', 'gamma4'])\n",
|
||||
"problem.discretise_domain(1000, 'random', domains=['phys_cond', 'time_cond', 'bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])\n",
|
||||
"\n",
|
||||
"# crete the solver\n",
|
||||
"pinn = PINN(problem, HardMLPtime(len(problem.input_variables), len(problem.output_variables)))\n",
|
||||
@@ -525,11 +525,8 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "56be7540488f3dc66429ddf54a0fa9de50124d45fcfccfaf04c4c3886d735a3a"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -543,7 +540,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
16
tutorials/tutorial3/tutorial.py
vendored
16
tutorials/tutorial3/tutorial.py
vendored
@@ -69,12 +69,12 @@ class Wave(TimeDependentProblem, SpatialProblem):
|
||||
return output_.extract(['u']) - u_expected
|
||||
|
||||
conditions = {
|
||||
'gamma1': Condition(location=CartesianDomain({'x': [0, 1], 'y': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma2': Condition(location=CartesianDomain({'x': [0, 1], 'y': 0, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma3': Condition(location=CartesianDomain({'x': 1, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'gamma4': Condition(location=CartesianDomain({'x': 0, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
't0': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'D': Condition(location=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': [0, 1]}), equation=Equation(wave_equation)),
|
||||
'bound_cond1': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 1, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond2': Condition(domain=CartesianDomain({'x': [0, 1], 'y': 0, 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond3': Condition(domain=CartesianDomain({'x': 1, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'bound_cond4': Condition(domain=CartesianDomain({'x': 0, 'y': [0, 1], 't': [0, 1]}), equation=FixedValue(0.)),
|
||||
'time_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': 0}), equation=Equation(initial_condition)),
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [0, 1], 'y': [0, 1], 't': [0, 1]}), equation=Equation(wave_equation)),
|
||||
}
|
||||
|
||||
def wave_sol(self, pts):
|
||||
@@ -123,7 +123,7 @@ class HardMLP(torch.nn.Module):
|
||||
|
||||
|
||||
# generate the data
|
||||
problem.discretise_domain(1000, 'random', locations=['D', 't0', 'gamma1', 'gamma2', 'gamma3', 'gamma4'])
|
||||
problem.discretise_domain(1000, 'random', domains=['phys_cond', 'time_cond', 'bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])
|
||||
|
||||
# crete the solver
|
||||
pinn = PINN(problem, HardMLP(len(problem.input_variables), len(problem.output_variables)))
|
||||
@@ -188,7 +188,7 @@ class HardMLPtime(torch.nn.Module):
|
||||
|
||||
|
||||
# generate the data
|
||||
problem.discretise_domain(1000, 'random', locations=['D', 't0', 'gamma1', 'gamma2', 'gamma3', 'gamma4'])
|
||||
problem.discretise_domain(1000, 'random', domains=['phys_cond', 'time_cond', 'bound_cond1', 'bound_cond2', 'bound_cond3', 'bound_cond4'])
|
||||
|
||||
# crete the solver
|
||||
pinn = PINN(problem, HardMLPtime(len(problem.input_variables), len(problem.output_variables)))
|
||||
|
||||
203
tutorials/tutorial5/tutorial.ipynb
vendored
203
tutorials/tutorial5/tutorial.ipynb
vendored
File diff suppressed because one or more lines are too long
12
tutorials/tutorial5/tutorial.py
vendored
12
tutorials/tutorial5/tutorial.py
vendored
@@ -9,7 +9,7 @@
|
||||
# In this tutorial we are going to solve the Darcy flow problem in two dimensions, presented in [*Fourier Neural Operator for
|
||||
# Parametric Partial Differential Equation*](https://openreview.net/pdf?id=c8P9NQVtmnO). First of all we import the modules needed for the tutorial. Importing `scipy` is needed for input-output operations.
|
||||
|
||||
# In[1]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
## routine needed to run the notebook on Google Colab
|
||||
@@ -89,7 +89,7 @@ u_train.labels[3]['dof']
|
||||
|
||||
# We now create the neural operator class. It is a very simple class, inheriting from `AbstractProblem`.
|
||||
|
||||
# In[5]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
class NeuralOperatorSolver(AbstractProblem):
|
||||
@@ -98,7 +98,7 @@ class NeuralOperatorSolver(AbstractProblem):
|
||||
domains = {
|
||||
'pts': k_train
|
||||
}
|
||||
conditions = {'data' : Condition(domain='pts',
|
||||
conditions = {'data' : Condition(domain='pts', #not among allowed pairs!!!
|
||||
output_points=u_train)}
|
||||
|
||||
# make problem
|
||||
@@ -188,9 +188,3 @@ print(f'Final error testing {err:.2f}%')
|
||||
# ## What's next?
|
||||
#
|
||||
# We have made a very simple example on how to use the `FNO` for learning neural operator. Currently in **PINA** we implement 1D/2D/3D cases. We suggest to extend the tutorial using more complex problems and train for longer, to see the full potential of neural operators.
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
26
tutorials/tutorial7/tutorial.ipynb
vendored
26
tutorials/tutorial7/tutorial.ipynb
vendored
@@ -50,7 +50,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"id": "00d1027d-13f2-4619-9ff7-a740568f13ff",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -78,7 +78,7 @@
|
||||
"from pina.equation import Equation, FixedValue\n",
|
||||
"from pina import Condition, Trainer\n",
|
||||
"from pina.solvers import PINN\n",
|
||||
"from pina.geometry import CartesianDomain"
|
||||
"from pina.domain import CartesianDomain"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -155,7 +155,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"id": "8ec0d95d-72c2-40a4-a310-21c3d6fe17d2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -188,19 +188,19 @@
|
||||
"\n",
|
||||
" # define the conditions for the loss (boundary conditions, equation, data)\n",
|
||||
" conditions = {\n",
|
||||
" 'gamma1': Condition(location=CartesianDomain({'x': [x_min, x_max],\n",
|
||||
" 'bound_cond1': Condition(domain=CartesianDomain({'x': [x_min, x_max],\n",
|
||||
" 'y': y_max}),\n",
|
||||
" equation=FixedValue(0.0, components=['u'])),\n",
|
||||
" 'gamma2': Condition(location=CartesianDomain({'x': [x_min, x_max], 'y': y_min\n",
|
||||
" 'bound_cond2': Condition(domain=CartesianDomain({'x': [x_min, x_max], 'y': y_min\n",
|
||||
" }),\n",
|
||||
" equation=FixedValue(0.0, components=['u'])),\n",
|
||||
" 'gamma3': Condition(location=CartesianDomain({'x': x_max, 'y': [y_min, y_max]\n",
|
||||
" 'bound_cond3': Condition(domain=CartesianDomain({'x': x_max, 'y': [y_min, y_max]\n",
|
||||
" }),\n",
|
||||
" equation=FixedValue(0.0, components=['u'])),\n",
|
||||
" 'gamma4': Condition(location=CartesianDomain({'x': x_min, 'y': [y_min, y_max]\n",
|
||||
" 'bound_cond4': Condition(domain=CartesianDomain({'x': x_min, 'y': [y_min, y_max]\n",
|
||||
" }),\n",
|
||||
" equation=FixedValue(0.0, components=['u'])),\n",
|
||||
" 'D': Condition(location=CartesianDomain({'x': [x_min, x_max], 'y': [y_min, y_max]\n",
|
||||
" 'phys_cond': Condition(domain=CartesianDomain({'x': [x_min, x_max], 'y': [y_min, y_max]\n",
|
||||
" }),\n",
|
||||
" equation=Equation(laplace_equation)),\n",
|
||||
" 'data': Condition(input_points=data_input.extract(['x', 'y']), output_points=data_output)\n",
|
||||
@@ -242,14 +242,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"id": "e3e0ae40-d8c6-4c08-81e8-85adc60a94e6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"problem.discretise_domain(20, 'grid', locations=['D'], variables=['x', 'y'])\n",
|
||||
"problem.discretise_domain(1000, 'random', locations=['gamma1', 'gamma2',\n",
|
||||
" 'gamma3', 'gamma4'], variables=['x', 'y'])"
|
||||
"problem.discretise_domain(20, 'grid', locations=['phys_cond'], variables=['x', 'y'])\n",
|
||||
"problem.discretise_domain(1000, 'random', locations=['bound_cond1', 'bound_cond2',\n",
|
||||
" 'bound_cond3', 'bound_cond4'], variables=['x', 'y'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -368,7 +368,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.8"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
22
tutorials/tutorial7/tutorial.py
vendored
22
tutorials/tutorial7/tutorial.py
vendored
@@ -25,7 +25,7 @@
|
||||
|
||||
# Let's start with useful imports.
|
||||
|
||||
# In[1]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
## routine needed to run the notebook on Google Colab
|
||||
@@ -81,7 +81,7 @@ plt.show()
|
||||
|
||||
# Then, we initialize the Poisson problem, that is inherited from the `SpatialProblem` and from the `InverseProblem` classes. We here have to define all the variables, and the domain where our unknown parameters ($\mu_1$, $\mu_2$) belong. Notice that the Laplace equation takes as inputs also the unknown variables, that will be treated as parameters that the neural network optimizes during the training process.
|
||||
|
||||
# In[4]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
### Define ranges of variables
|
||||
@@ -112,19 +112,19 @@ class Poisson(SpatialProblem, InverseProblem):
|
||||
|
||||
# define the conditions for the loss (boundary conditions, equation, data)
|
||||
conditions = {
|
||||
'gamma1': Condition(location=CartesianDomain({'x': [x_min, x_max],
|
||||
'bound_cond1': Condition(domain=CartesianDomain({'x': [x_min, x_max],
|
||||
'y': y_max}),
|
||||
equation=FixedValue(0.0, components=['u'])),
|
||||
'gamma2': Condition(location=CartesianDomain({'x': [x_min, x_max], 'y': y_min
|
||||
'bound_cond2': Condition(domain=CartesianDomain({'x': [x_min, x_max], 'y': y_min
|
||||
}),
|
||||
equation=FixedValue(0.0, components=['u'])),
|
||||
'gamma3': Condition(location=CartesianDomain({'x': x_max, 'y': [y_min, y_max]
|
||||
'bound_cond3': Condition(domain=CartesianDomain({'x': x_max, 'y': [y_min, y_max]
|
||||
}),
|
||||
equation=FixedValue(0.0, components=['u'])),
|
||||
'gamma4': Condition(location=CartesianDomain({'x': x_min, 'y': [y_min, y_max]
|
||||
'bound_cond4': Condition(domain=CartesianDomain({'x': x_min, 'y': [y_min, y_max]
|
||||
}),
|
||||
equation=FixedValue(0.0, components=['u'])),
|
||||
'D': Condition(location=CartesianDomain({'x': [x_min, x_max], 'y': [y_min, y_max]
|
||||
'phys_cond': Condition(domain=CartesianDomain({'x': [x_min, x_max], 'y': [y_min, y_max]
|
||||
}),
|
||||
equation=Equation(laplace_equation)),
|
||||
'data': Condition(input_points=data_input.extract(['x', 'y']), output_points=data_output)
|
||||
@@ -148,12 +148,12 @@ model = FeedForward(
|
||||
|
||||
# After that, we discretize the spatial domain.
|
||||
|
||||
# In[6]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
problem.discretise_domain(20, 'grid', locations=['D'], variables=['x', 'y'])
|
||||
problem.discretise_domain(1000, 'random', locations=['gamma1', 'gamma2',
|
||||
'gamma3', 'gamma4'], variables=['x', 'y'])
|
||||
problem.discretise_domain(20, 'grid', locations=['phys_cond'], variables=['x', 'y'])
|
||||
problem.discretise_domain(1000, 'random', locations=['bound_cond1', 'bound_cond2',
|
||||
'bound_cond3', 'bound_cond4'], variables=['x', 'y'])
|
||||
|
||||
|
||||
# Here, we define a simple callback for the trainer. We use this callback to save the parameters predicted by the neural network during the training. The parameters are saved every 100 epochs as `torch` tensors in a specified directory (`tmp_dir` in our case).
|
||||
|
||||
16
tutorials/tutorial8/tutorial.ipynb
vendored
16
tutorials/tutorial8/tutorial.ipynb
vendored
@@ -64,7 +64,7 @@
|
||||
"import torch\n",
|
||||
"import pina\n",
|
||||
"\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"\n",
|
||||
"from pina.problem import ParametricProblem\n",
|
||||
"from pina.model.layers import PODBlock, RBFBlock\n",
|
||||
@@ -80,7 +80,7 @@
|
||||
"id": "5138afdf-bff6-46bf-b423-a22673190687",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We exploit the [Smithers](www.github.com/mathLab/Smithers) library to collect the parametric snapshots. In particular, we use the `NavierStokesDataset` class that contains a set of parametric solutions of the Navier-Stokes equations in a 2D L-shape domain. The parameter is the inflow velocity.\n",
|
||||
"We exploit the [Smithers](https://github.com/mathLab/Smithers) library to collect the parametric snapshots. In particular, we use the `NavierStokesDataset` class that contains a set of parametric solutions of the Navier-Stokes equations in a 2D L-shape domain. The parameter is the inflow velocity.\n",
|
||||
"The dataset is composed by 500 snapshots of the velocity (along $x$, $y$, and the magnitude) and pressure fields, and the corresponding parameter values.\n",
|
||||
"\n",
|
||||
"To visually check the snapshots, let's plot also the data points and the reference solution: this is the expected output of our model."
|
||||
@@ -106,6 +106,8 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install git+https://github.com/mathLab/Smithers.git\n",
|
||||
"import smithers\n",
|
||||
"from smithers.dataset import NavierStokesDataset\n",
|
||||
"dataset = NavierStokesDataset()\n",
|
||||
"\n",
|
||||
@@ -549,14 +551,6 @@
|
||||
" \n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d3758c39",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@@ -575,7 +569,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.8"
|
||||
"version": "3.12.3"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
||||
10
tutorials/tutorial8/tutorial.py
vendored
10
tutorials/tutorial8/tutorial.py
vendored
@@ -46,7 +46,7 @@ from pina.solvers import SupervisedSolver
|
||||
print(f'We are using PINA version {pina.__version__}')
|
||||
|
||||
|
||||
# We exploit the [Smithers](www.github.com/mathLab/Smithers) library to collect the parametric snapshots. In particular, we use the `NavierStokesDataset` class that contains a set of parametric solutions of the Navier-Stokes equations in a 2D L-shape domain. The parameter is the inflow velocity.
|
||||
# We exploit the [Smithers](https://github.com/mathLab/Smithers) library to collect the parametric snapshots. In particular, we use the `NavierStokesDataset` class that contains a set of parametric solutions of the Navier-Stokes equations in a 2D L-shape domain. The parameter is the inflow velocity.
|
||||
# The dataset is composed by 500 snapshots of the velocity (along $x$, $y$, and the magnitude) and pressure fields, and the corresponding parameter values.
|
||||
#
|
||||
# To visually check the snapshots, let's plot also the data points and the reference solution: this is the expected output of our model.
|
||||
@@ -54,6 +54,8 @@ print(f'We are using PINA version {pina.__version__}')
|
||||
# In[2]:
|
||||
|
||||
|
||||
get_ipython().system('pip install git+https://github.com/mathLab/Smithers.git')
|
||||
import smithers
|
||||
from smithers.dataset import NavierStokesDataset
|
||||
dataset = NavierStokesDataset()
|
||||
|
||||
@@ -303,9 +305,3 @@ for i, (idx_, rbf_, nn_, rbf_err_, nn_err_) in enumerate(
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12
tutorials/tutorial9/tutorial.ipynb
vendored
12
tutorials/tutorial9/tutorial.ipynb
vendored
@@ -43,7 +43,7 @@
|
||||
"from pina.model.layers import PeriodicBoundaryEmbedding # The PBC module\n",
|
||||
"from pina.solvers import PINN\n",
|
||||
"from pina.trainer import Trainer\n",
|
||||
"from pina.geometry import CartesianDomain\n",
|
||||
"from pina.domain import CartesianDomain\n",
|
||||
"from pina.equation import Equation"
|
||||
]
|
||||
},
|
||||
@@ -77,7 +77,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -94,7 +94,7 @@
|
||||
"\n",
|
||||
" # here we write the problem conditions\n",
|
||||
" conditions = {\n",
|
||||
" 'D': Condition(location=spatial_domain,\n",
|
||||
" 'phys_cond': Condition(domain=spatial_domain,\n",
|
||||
" equation=Equation(Helmholtz_equation)),\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
@@ -106,7 +106,7 @@
|
||||
"problem = Helmholtz()\n",
|
||||
"\n",
|
||||
"# let's discretise the domain\n",
|
||||
"problem.discretise_domain(200, 'grid', locations=['D'])"
|
||||
"problem.discretise_domain(200, 'grid', domains=['phys_cond'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -293,7 +293,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "pina",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -307,7 +307,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
6
tutorials/tutorial9/tutorial.py
vendored
6
tutorials/tutorial9/tutorial.py
vendored
@@ -63,7 +63,7 @@ from pina.equation import Equation
|
||||
# and $f(x)=-6\pi^2\sin(3\pi x)\cos(\pi x)$ which give a solution that can be
|
||||
# computed analytically $u(x) = \sin(\pi x)\cos(3\pi x)$.
|
||||
|
||||
# In[2]:
|
||||
# In[ ]:
|
||||
|
||||
|
||||
class Helmholtz(SpatialProblem):
|
||||
@@ -79,7 +79,7 @@ class Helmholtz(SpatialProblem):
|
||||
|
||||
# here we write the problem conditions
|
||||
conditions = {
|
||||
'D': Condition(location=spatial_domain,
|
||||
'phys_cond': Condition(domain=spatial_domain,
|
||||
equation=Equation(Helmholtz_equation)),
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class Helmholtz(SpatialProblem):
|
||||
problem = Helmholtz()
|
||||
|
||||
# let's discretise the domain
|
||||
problem.discretise_domain(200, 'grid', locations=['D'])
|
||||
problem.discretise_domain(200, 'grid', domains=['phys_cond'])
|
||||
|
||||
|
||||
# As usual, the Helmholtz problem is written in **PINA** code as a class.
|
||||
|
||||
Reference in New Issue
Block a user