Update tutorials 1 through 12 to current version 0.2

This commit is contained in:
Matteo Bertocchi
2025-02-26 16:21:12 +01:00
committed by Nicola Demo
parent 8b797d589a
commit d83ca3af6e
82 changed files with 1074 additions and 1224 deletions

File diff suppressed because one or more lines are too long

View File

@@ -24,13 +24,13 @@ if IN_COLAB:
import torch
from pina.problem import SpatialProblem, TimeDependentProblem
from pina.operators import laplacian, grad
from pina.operator import laplacian, grad
from pina.domain import CartesianDomain
from pina.solvers import PINN
from pina.solver import PINN
from pina.trainer import Trainer
from pina.equation import Equation
from pina.equation.equation_factory import FixedValue
from pina import Condition, Plotter
from pina import Condition
# ## The problem definition
@@ -138,19 +138,19 @@ trainer.train()
# In[5]:
plotter = Plotter()
#plotter = Plotter()
# plotting at fixed time t = 0.0
print('Plotting at t=0')
plotter.plot(pinn, fixed_variables={'t': 0.0})
#print('Plotting at t=0')
#plotter.plot(pinn, fixed_variables={'t': 0.0})
# plotting at fixed time t = 0.5
print('Plotting at t=0.5')
plotter.plot(pinn, fixed_variables={'t': 0.5})
#print('Plotting at t=0.5')
#plotter.plot(pinn, fixed_variables={'t': 0.5})
# plotting at fixed time t = 1.
print('Plotting at t=1')
plotter.plot(pinn, fixed_variables={'t': 1.0})
#print('Plotting at t=1')
#plotter.plot(pinn, fixed_variables={'t': 1.0})
# The results are not so great, and we can clearly see that as time progress the solution gets worse.... Can we do better?
@@ -203,19 +203,19 @@ trainer.train()
# In[8]:
plotter = Plotter()
#plotter = Plotter()
# plotting at fixed time t = 0.0
print('Plotting at t=0')
plotter.plot(pinn, fixed_variables={'t': 0.0})
#print('Plotting at t=0')
#plotter.plot(pinn, fixed_variables={'t': 0.0})
# plotting at fixed time t = 0.5
print('Plotting at t=0.5')
plotter.plot(pinn, fixed_variables={'t': 0.5})
#print('Plotting at t=0.5')
#plotter.plot(pinn, fixed_variables={'t': 0.5})
# plotting at fixed time t = 1.
print('Plotting at t=1')
plotter.plot(pinn, fixed_variables={'t': 1.0})
#print('Plotting at t=1')
#plotter.plot(pinn, fixed_variables={'t': 1.0})
# We can see now that the results are way better! This is due to the fact that previously the network was not learning correctly the initial conditon, leading to a poor solution when time evolved. By imposing the initial condition the network is able to correctly solve the problem.