scimba_torch.numerical_solvers.temporal_pde.neural_semilagrangian¶
Implement the Neural Semi-Lagrangian scheme.
Classes
| 
 | Class to handle the characteristics of a PDE. | 
| 
 | Implement the Neural Semi-Lagrangian scheme. | 
- class Characteristic(pde, **kwargs)[source]¶
- Bases: - object- Class to handle the characteristics of a PDE. - Parameters:
- pde ( - AdvectionReactionDiffusion) – The PDE for which to compute characteristics.
- **kwargs – Additional keyword arguments. 
 
 - make_diffusion_directions(kind='directionwise')[source]¶
- Creates the diffusion directions based on the chosen kind. - Parameters:
- kind ( - str) – The kind of diffusion directions to create (Default: “directionwise”).
- Return type:
- Tensor
- Returns:
- The created diffusion directions. 
 
 - ensure_periodicity(y)[source]¶
- Ensures that the points x are within the domain bounds. - If the points are outside the bounds, they are wrapped around the domain. - Parameters:
- y ( - Tensor) – The points.
- Returns:
- The points within the domain bounds. 
 
 - exact_foot_constant_advection(t, x, mu, dt)[source]¶
- Computes the foot of the (backwards) characteristic curve. - The curve is originating from point x at time t + dt, towards point y at time t. - In the case of constant advection, the foot is given by y = x - a * dt. - Parameters:
- t ( - Tensor) – The current time.
- x ( - Tensor) – The current points.
- mu ( - Tensor) – The physical parameters.
- dt ( - float) – The time step.
 
- Return type:
- Tensor
- Returns:
- The foot of the characteristic curve. 
 
 - static backwards_ode_integrator(f, t, x, mu, dt, scheme='rk4')[source]¶
- Computes the solution of the ODE dx/dt = f(t, x, mu) at time t - dt. - Use a numerical scheme. - Parameters:
- f ( - Callable) – The function defining the ODE.
- t ( - Tensor) – The current time.
- x ( - Tensor) – The current points.
- mu ( - Tensor) – The physical parameters.
- dt ( - float) – The time step.
- scheme ( - str) – The numerical scheme used for integrating the ODE. Default is “rk4”.
 
- Return type:
- Tensor
- Returns:
- The numberical solution at time t - dt. 
 
 - numerical_foot(t, x, mu, dt, **kwargs)[source]¶
- Computes the foot of the (backwards) characteristic curve. - The curve is originating from point x at time t + dt, towards point y at time t. - In the case of non-constant advection, the foot is computed using a numerical scheme, with n_sub_steps sub-steps. - Parameters:
- t ( - Tensor) – The current time.
- x ( - Tensor) – The current points.
- mu ( - Tensor) – The physical parameters.
- dt ( - float) – The time step.
- **kwargs – - Additional keyword arguments including: - scheme (str): The numerical scheme used for integrating the ODE. Default is “rk4”. 
- n_sub_steps (int): The number of sub-steps used for integrating the ODE. Default is 5. 
 
 
- Returns:
- The foot of the characteristic curve. 
- Return type:
- torch.Tensor 
 
 - get_foot(t, x, mu, dt, **kwargs)[source]¶
- Computes the foot of the (backwards) characteristic curve. - The curve is originating from point x at time t + dt, towards point y at time t. - If an exact foot is provided, it is used. Otherwise, a numerical foot is computed. - Periodic and flipped periodic boundary conditions are supported. - Parameters:
- t ( - LabelTensor) – The current time.
- x ( - LabelTensor) – The current points.
- mu ( - LabelTensor) – The physical parameters.
- dt ( - float) – The time step.
- **kwargs – - Additional keyword arguments including: - scheme (str): The numerical scheme used for integrating the ODE, in case no exact foot is provided. Default is “rk4”. 
- n_sub_steps (int): The number of sub-steps used for integrating the ODE, in case no exact foot is provided. Default is 5. 
 
 
- Return type:
- Returns:
- The foot of the characteristic curve. 
 
 - get_foot_kinetic_pde(t, x, v, mu, dt, **kwargs)[source]¶
- Computes the foot of the (backwards) characteristic curve for a kinetic PDE. - Use get_foot. - Parameters:
- t ( - LabelTensor) – The current time.
- x ( - LabelTensor) – The current points.
- v ( - LabelTensor) – The velocity points.
- mu ( - LabelTensor) – The physical parameters.
- dt ( - float) – The time step.
- **kwargs – - Additional keyword arguments including: - scheme (str): The numerical scheme used for integrating the ODE, in case no exact foot is provided. Default is “rk4”. 
- n_sub_steps (int): The number of sub-steps used for integrating the ODE, in case no exact foot is provided. Default is 5. 
 
 
- Return type:
- Returns:
- The foot of the characteristic curve. 
 
 
- class NeuralSemiLagrangian(characteristic, projector, **kwargs)[source]¶
- Bases: - ExplicitTimeDiscreteScheme- Implement the Neural Semi-Lagrangian scheme. - Parameters:
- characteristic ( - Characteristic) – The characteristics model.
- projector ( - AbstractNonlinearProjector) – The projector for training the model.
- **kwargs – Additional hyperparameters for the scheme. 
 
 - construct_rhs(pde_n, t, dt, **kwargs)[source]¶
- Constructs the RHS of the Neural Semi-Lagrangian scheme. - Computes the foot of the characteristic curve originating from point x at time t + dt, towards point y at time t. - Parameters:
- pde_n ( - AdvectionReactionDiffusion) – The PDE to solve at the current time step.
- t ( - float) – The current time.
- dt ( - float) – The time step.
- **kwargs – - Additional keyword arguments including: - scheme (str): The numerical scheme used for integrating the ODE, in case no exact foot is provided. Default is “rk4”. 
- n_sub_steps (int): The number of sub-steps used for integrating the ODE, in case no exact foot is provided. Default is 5. 
 
 
- Return type:
- Callable
- Returns:
- The RHS function for the Neural Semi-Lagrangian scheme.