phlearn.phsystems
The phsystems subpackage is divided into two further subpackages, one for ODEs and one for PDEs. These implement pseudo-Hamiltonian systems and numerical integration of these to obtain data.
- class phlearn.phsystems.AllenCahnSystem(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]), nu=0.001, init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemImplements a discretization of the Allen-Cahn equation with an optional external force, as described by
u_t - u_xx - u + u^3 = f(u,t,x)
on the pseudo-Hamiltonian formulation
du/dt = -grad[V(u)] + F(u,t,x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 1.0 - 1/100, 100)
The spatial discretization points.
- nunumber, default -1.0
The parameter nu in the Cahn-Hilliard equation.
- alphanumber, default 1.0
The parameter alpha in the Cahn-Hilliard equation.
- munumber, default -0.001
The parameter mu in the Cahn-Hilliard equation.
- init_samplercallable, default None
Function for sampling initial conditions. Callable taking a numpy random generator as input and returning an ndarray of shape same as x with initial conditions for the system. This sampler is used when calling CahnHilliardSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.BBMSystem(x=array([0., 0.2, 0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8, 2., 2.2, 2.4, 2.6, 2.8, 3., 3.2, 3.4, 3.6, 3.8, 4., 4.2, 4.4, 4.6, 4.8, 5., 5.2, 5.4, 5.6, 5.8, 6., 6.2, 6.4, 6.6, 6.8, 7., 7.2, 7.4, 7.6, 7.8, 8., 8.2, 8.4, 8.6, 8.8, 9., 9.2, 9.4, 9.6, 9.8, 10., 10.2, 10.4, 10.6, 10.8, 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13., 13.2, 13.4, 13.6, 13.8, 14., 14.2, 14.4, 14.6, 14.8, 15., 15.2, 15.4, 15.6, 15.8, 16., 16.2, 16.4, 16.6, 16.8, 17., 17.2, 17.4, 17.6, 17.8, 18., 18.2, 18.4, 18.6, 18.8, 19., 19.2, 19.4, 19.6, 19.8]), nu=0.0, init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemBBMSystem class, representing a discretization of the Benjamin-Bona-Mahony (BBM) equation.
Implements a discretization of the BBM equation with an optional viscosity term and external forces:
u_t - u_xxt + u_x + u u_x - nu u_xx = f(u,x,t)
on the pseudo-Hamiltonian formulation
(1-d^2/dx^2)(du/dt) = d/dx(grad[H(u)]) - grad[V(u)] + F(u, t, x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 20.0 - 0.2, 100)
The spatial discretization points
- nunumber, default 0.0
The damping coefficient
- init_samplercallable, default None
Function for sampling initial conditions. Callable taking a numpy random generator as input and returning an ndarray of shape same as x with initial conditions for the system. This sampler is used when calling BBMSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.CahnHilliardSystem(x=array([0., 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99]), nu=-1.0, alpha=1.0, mu=-0.001, init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemImplements a discretization of the Cahn-Hilliard equation with an optional external force, as described by
u_t - (nu u + alpha u^3 + mu u_xx)_xx = f(u,t,x)
on the pseudo-Hamiltonian formulation
du/dt = d^2/dx^2 grad[V(u)] + F(u,t,x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 1.0 - 1/100, 100)
The spatial discretization points.
- nunumber, default -1.0
The parameter nu in the Cahn-Hilliard equation.
- alphanumber, default 1.0
The parameter alpha in the Cahn-Hilliard equation.
- munumber, default -0.001
The parameter mu in the Cahn-Hilliard equation.
- init_samplercallable, default None
Function for sampling initial conditions. Callable taking a numpy random generator as input and returning an ndarray of shape same as x with initial conditions for the system. This sampler is used when calling CahnHilliardSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.HeatEquationSystem(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]), nu=1.0, init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemImplements a discretization of the heat equation with an optional external force,
u_t - u_xx = f(u,t,x),
on the pseudo-Hamiltonian formulation
du/dt = -grad[V(u)] + F(u,t,x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 1.0 - 1/100, 100)
The spatial discretization points.
- nunumber, default -1.0
The parameter nu in the Cahn-Hilliard equation.
- alphanumber, default 1.0
The parameter alpha in the Cahn-Hilliard equation.
- munumber, default -0.001
The parameter mu in the Cahn-Hilliard equation.
- init_samplercallable, default None
Function for sampling initial conditions. Callable taking a numpy random generator as input and returning an ndarray of shape same as x with initial conditions for the system. This sampler is used when calling CahnHilliardSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.KdVSystem(x=array([0., 0.2, 0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8, 2., 2.2, 2.4, 2.6, 2.8, 3., 3.2, 3.4, 3.6, 3.8, 4., 4.2, 4.4, 4.6, 4.8, 5., 5.2, 5.4, 5.6, 5.8, 6., 6.2, 6.4, 6.6, 6.8, 7., 7.2, 7.4, 7.6, 7.8, 8., 8.2, 8.4, 8.6, 8.8, 9., 9.2, 9.4, 9.6, 9.8, 10., 10.2, 10.4, 10.6, 10.8, 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13., 13.2, 13.4, 13.6, 13.8, 14., 14.2, 14.4, 14.6, 14.8, 15., 15.2, 15.4, 15.6, 15.8, 16., 16.2, 16.4, 16.6, 16.8, 17., 17.2, 17.4, 17.6, 17.8, 18., 18.2, 18.4, 18.6, 18.8, 19., 19.2, 19.4, 19.6, 19.8]), eta=6.0, gamma=1.0, nu=0.0, init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemImplements the a discretization of the KdV-Burgers equation with an optional external force,
u_t + eta u u_x - nu u_xx - gamma^2 u_xxx = f(u,x,t)
on the pseudo-Hamiltonian formulation
du/dt = d/dx(grad[H(u)]) - grad[V(u)] + F(u, t, x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 20.0 - 0.2, 100)
The spatial discretization points
- etanumber, default 6.0
The parameter eta in the KdV equation
- gammanumber, default 1.0
The parameter gamma in the KdV equation
- nunumber, default 0.0
The damping coefficient
- init_samplercallable, default None
Function for sampling initial conditions. Callabale taking a numpy random generator as input and returning an ndarray of shape same as x with inital conditions for the system. This sampler is used when calling KdVSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.MassSpringDamperSystem(mass=1.0, spring_constant=1.0, damping=0.3, **kwargs)
Bases:
PseudoHamiltonianSystemImplements a general forced and damped mass-spring system as a pseudo-Hamiltonian formulation:
. | q | | 0 1 | | 0 | | . | = | | * grad[H(q, p)] + | | | p | | -1 -c | | f(q, p, t) |
where q is the position, p the momentum and c the damping coefficient.
- Parameters
- massnumber, default 1.0
Scalar mass
- spring_constantnumber, default 1.0
Scalar spring coefficient
- dampingnumber, default 0.3
Scalar damping coefficient. Corresponds to c.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianSystem constructor.
- class phlearn.phsystems.PeronaMalikSystem(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]), init_sampler=None, **kwargs)
Bases:
PseudoHamiltonianPDESystemImplements a discretization of the Perona-Malik equation with an optional external force,
u_t + (u_x/(1+u_x^2))_x = f(u,t,x),
on the pseudo-Hamiltonian formulation
du/dt = -grad[V(u)] + F(u,t,x)
where u is a vector of the system states at the spatial points given by x, and t is time.
The system is by default integrated in time using the implicit midpoint method. The line ‘self.sample_trajectory = self.sample_trajectory_midpoint’ can be commented out to instead use the RK45 method of scipy.
- Parameters
- xnparray, default np.linspace(0, 1.0 - 1/100, 100)
The spatial discretization points.
- nunumber, default -1.0
The parameter nu in the Cahn-Hilliard equation.
- alphanumber, default 1.0
The parameter alpha in the Cahn-Hilliard equation.
- munumber, default -0.001
The parameter mu in the Cahn-Hilliard equation.
- init_samplercallable, default None
Function for sampling initial conditions. Callable taking a numpy random generator as input and returning an ndarray of shape same as x with initial conditions for the system. This sampler is used when calling CahnHilliardSystem.sample_trajectory if no initial condition is provided.
- kwargsany, optional
Keyword arguments that are passed to PseudoHamiltonianPDESystem constructor.
- class phlearn.phsystems.PseudoHamiltonianPDESystem(nstates, lhs_matrix=None, skewsymmetric_matrix=None, dissipation_matrix=None, hamiltonian=None, dissintegral=None, grad_hamiltonian=None, grad_dissintegral=None, hess_hamiltonian=None, hess_dissintegral=None, external_forces=None, jac_external_forces=None, controller=None, init_sampler=None)
Bases:
objectImplements a spatially discretized pseudo-Hamiltonian PDE system of the form:
dx/dt = S*grad[H(x)] - R*grad[V(x)] + F(x, t, xspatial)
where x is the system state, A is a symmetric matrix, S is a skew-symmetric matrix, R is the symmetric dissipation matrix, H and V are discretized integrals of the systemm, F is the external force depending on state, time and space.
What is x here is usually u in the literature, and xspatial is x. We use x for the state to be consistent with the ODE case.
- Parameters
- nstatesint
Number of system states N.
- skewsymmetric_matrix(N, N) ndarray or callable, default None
Corresponds to the S matrix. Must either be an ndarray, or callable taking an ndarray input of shape (nsamples, nstates) and returning an ndarray of shape (nsamples, nstates, nstates). If None, the system is assumed to be canonical, and the S matrix is set ot the skew-symmetric matrix [[0, I_n], [-I_n, 0]].
- hamiltoniancallable, default None
The Hamiltonian H of the system. Callable taking a torch tensor input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, 1). If the gradient of the Hamiltonian is not provided, the gradient of this function will be computed by torch and used instead. If this is not provided, the grad_hamiltonian must be provided.
- dissintegralcallable, default None
The dissipating integral V of the system. Callable taking a torch tensor input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, 1). If the gradient of the dissipating integral is not provided, the gradient of this function will be computed by torch and used instead. If this is not provided, the grad_dissintegral must be provided.
- grad_hamiltoniancallable, default None
The gradient of the Hamiltonian H of the system. Callable taking an ndarray input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, nstates). If this is not provided, the hamiltonian must be provided.
- grad_dissintegralcallable, default None
The gradient of the dissipating integral V of the system. Callable taking an ndarray input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, nstates). If this is not provided, the hamiltonian must be provided.
- external_forcescallable, default None
The external forces affecting system. Callable taking two ndarrays as input, x and t, of shape (nsamples, nstates), (nsamples, 1), respectively and returning an ndarray of shape (nsamples, nstates).
- controllerphlearn.control.PseudoHamiltonianController,
- default None
Additional external forces set by a controller. Callable taking an ndarray x of shape (nstates,) and a scalar t as input and returning an ndarray of shape (nstates,). Note that this function should not take batch inputs, and that when calling PseudoHamiltonianSystem.sample_trajectory when a controller is provided, the Runge-Kutta 4 method will be used for integration in favor of Scipy’s solve_ivp.
- init_samplercallable, default None
Function for sampling initial conditions. Callabale taking a numpy random generator as input and returning an ndarray of shape (nstates,) with inital conditions for the system. This sampler is used when calling PseudoHamiltonianSystem.sample_trajectory if no initial condition is provided.
Methods
sample_trajectory(t[, x0, noise_std, reference])Samples a trajectory of the system at times t, found by using the solve_ivp solver for temporal integration, starting from the initial state x0.
sample_trajectory_midpoint(t[, x0, ...])Samples a trajectory of the system at times t, found by using the implicit midpoint method for temporal integration, starting from the initial state x0.
seed(seed)Set the internal random state.
time_derivative(integrator, *args, **kwargs)See :py:meth:~`utils.derivatives.time_derivative`
x_dot(x, t[, u])Computes the time derivative, the right hand side of the pseudo- Hamiltonian equation.
x_dot_jacobian(x, t[, u])Computes the Jacobian of the right hand side of the pseudo- Hamiltonian equation.
- sample_trajectory(t, x0=None, noise_std=0, reference=None)
Samples a trajectory of the system at times t, found by using the solve_ivp solver for temporal integration, starting from the initial state x0.
- Parameters
- t(T, 1) ndarray
Times at which the trajectory is sampled.
- x0(N,) ndarray, default None
Initial condition.
- noise_stdnumber, default 0.
Standard deviation of Gaussian white noise added to the samples of the trajectory.
- referencephlearn.control.Reference, default None
Not in use for now.
- Returns
- x(T, N) ndarray
- dxdt(T, N) ndarray
- t(T, 1) ndarray
- us(T, N) ndarray
- sample_trajectory_midpoint(t, x0=None, noise_std=0, reference=None)
Samples a trajectory of the system at times t, found by using the implicit midpoint method for temporal integration, starting from the initial state x0. Newton’s method is used for solving the system of nonlinear equations at each integration step.
- Parameters
- t(T, 1) ndarray
Times at which the trajectory is sampled.
- x0(N,) ndarray, default None
Initial condition.
- noise_stdnumber, default 0.
Standard deviation of Gaussian white noise added to the samples of the trajectory.
- referencephlearn.control.Reference, default None
Not in use for now.
- Returns
- x(T, N) ndarray
- dxdt(T, N) ndarray
- t(T, 1) ndarray
- us(T, N) ndarray
- seed(seed)
Set the internal random state.
- Parameters
- seedint
- time_derivative(integrator, *args, **kwargs)
See :py:meth:~`utils.derivatives.time_derivative`
- x_dot(x, t, u=None)
Computes the time derivative, the right hand side of the pseudo- Hamiltonian equation.
- Parameters
- x(…, N) ndarray
- t(…, 1) ndarray
- u(…, N) ndarray or None, default None
- Returns
- (…, N) ndarray
- x_dot_jacobian(x, t, u=None)
Computes the Jacobian of the right hand side of the pseudo- Hamiltonian equation.
- Parameters
- x(…, N) ndarray
- t(…, 1) ndarray
- u(…, N) ndarray or None, default None
- Returns
- (…, N) ndarray
- class phlearn.phsystems.PseudoHamiltonianSystem(nstates, skewsymmetric_matrix=None, dissipation_matrix=None, hamiltonian=None, grad_hamiltonian=None, external_forces=None, controller=None, init_sampler=None)
Bases:
objectImplements a pseudo-Hamiltonian system of the form:
dx/dt = (S(x) - R(x))*grad[H(x)] + F(x, t)
where x is the system state, S is the skew-symmetric interconnection matrix, R is the positive semi-definite dissipation matrix, H is the Hamiltonian of the systemm, F is the external force(s).
- Parameters
- nstatesint
Number of system states N.
- skewsymmetric_matrix(N, N) ndarray or callable, default None
Corresponds to the S matrix. Must either be an ndarray, or callable taking an ndarray input of shape (nsamples, nstates) and returning an ndarray of shape (nsamples, nstates, nstates). If None, the system is assumed to be canonical, and the S matrix is set to be [[0, I_N], [-I_N, 0]].
- dissipation_matrix(N, N) ndarray or callable, default None
Corresponds to the R matrix. Must either be an ndarray, or callable taking an ndarray input of shape (nsamples, nstates) and returning an ndarray of shape (nsamples, nstates, nstates). If None, the R matrix is set to be the zero matrix of shape (N, N).
- hamiltoniancallable, default None
The Hamiltonian H of the system. Callable taking a torch tensor input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, 1). If the gradient of the Hamiltonian is not provided, the gradient of this function will be computed by torch and used instead. If this is not provided, the grad_hamiltonian must be provided.
- grad_hamiltoniancallable, default None
The gradient of the Hamiltonian H of the system. Callable taking an ndarray input of shape (nsamples, nstates) and returning a torch tensor of shape (nsamples, nstates). If this is not provided, the hamiltonian must be provided.
- external_forcescallable, default None
The external forces affecting system. Callable taking two ndarrays as input, x and t, of shape (nsamples, nstates), (nsamples, 1), respectively and returning an ndarray of shape (nsamples, nstates).
- controllerphlearn.control.PseudoHamiltonianController,
- default None
Additional external forces set by a controller. Callable taking an ndarray x of shape (nstates,) and a scalar t as input and returning an ndarray of shape (nstates,). Note that this function should not take batch inputs, and that when calling PseudoHamiltonianSystem.sample_trajectory when a controller is provided, the Runge-Kutta 4 method will be used for integration in favor of Scipy’s solve_ivp.
- init_samplercallable, default None
Function for sampling initial conditions. Callabale taking a numpy random generator as input and returning an ndarray of shape (nstates,) with inital conditions for the system. This sampler is used when calling PseudoHamiltonianSystem.sample_trajectory if no initial condition is provided.
Methods
sample_trajectory(t[, x0, noise_std, reference])Samples a trajectory of the system at times t.
seed(seed)Set the internal random state.
set_controller(controller)Set system controller.
time_derivative(integrator, *args, **kwargs)See :py:meth:~`utils.derivatives.time_derivative`
x_dot(x, t[, u])Computes the time derivative by the right hand side of the pseudo- Hamiltonian equation.
- sample_trajectory(t, x0=None, noise_std=0, reference=None)
Samples a trajectory of the system at times t.
- Parameters
- t(T, 1) ndarray
Times at which the trajectory is sampled.
- x0(N,) ndarray, default None
Initial condition.
- noise_stdnumber, default 0.
Standard deviation of Gaussian white noise added to the samples of the trajectory.
- referencephlearn.control.Reference, default None
If the system has a controller a reference object may be passed.
- Returns
- x(T, N) ndarray
- dxdt(T, N) ndarray
- t(T, 1) ndarray
- us(T, N) ndarray
- seed(seed)
Set the internal random state.
- Parameters
- seedint
- set_controller(controller)
Set system controller.
- time_derivative(integrator, *args, **kwargs)
See :py:meth:~`utils.derivatives.time_derivative`
- x_dot(x, t, u=None)
Computes the time derivative by the right hand side of the pseudo- Hamiltonian equation.
- Parameters
- x(…, N) ndarray
- t(…, 1) ndarray
- u(…, N) ndarray or None, default None
- Returns
- (…, N) ndarray
- class phlearn.phsystems.TankSystem(incidence_matrix=None, system_graph=None, npipes=None, ntanks=None, dissipation_pipes=None, J=1.0, A=1.0, rho=1.0, g=9.81, **kwargs)
Bases:
PseudoHamiltonianSystemImplements a pseudo-Hamiltonian version of a coupled tanks system:
. | -R_p B^T | x = | | * grad[H(x)] + F(x, t) | -B 0 |
where the state x = [phi, mu], phi and mu being proportional to pipe flows and tank levels, respectively. The interconnection of the tanks is described by a directed graph where each vertex is a tank and each edge is a pipe between two tanks. The incidence matrix of this graph corresponds to the matrix B. The number of tanks is denoted by ntanks, the number of pipes by npipes. The number of states is denoted by nstates = npipes + ntanks.
External interaction can be specified for every state, but the most physically interpretable setting is to only have external interaction for the states corresponding to the tanks, which can be seen as volumetric flows into or out of the tanks.
Each tank is assumed to have a uniform cross-section w.r.t. it’s height.
The interconnection of tanks and pipes can either be specified by a directed graph or by an interconnection matrix S.
- Parameters
- incidence_matrix(N, N) ndarray, default None
Incidence matrix of the graph describing the tank system. Corresponds to the B matrix. Inferred from system_graph if system_graph is provided.
- system_graphnetworkx.Graph, default None
networkx directed graph describing the interconnection of the tanks. The graph has ntanks vertices and npipes edges.
- npipesint, default None
Number of pipes. Inferred from system_graph if system_graph is provided.
- ntanksint, default None
Number of tanks. Inferred from system_graph if system_graph is provided.
- dissipation_pipesndarray, default None
ndarray of size (npipes,) or (npipes, npipes), describing energy loss in the pipes. Corresponds to R_p. Defaults to zero if not provided.
- Jnumber, default 1.
Scalar or ndarray of size (npipes,) of proportionality constants relating the change in volumetric flow through each pipe to the pressure drop and potential friction through each pipe. If scalar, the same constant is used for all pipes.
- A(ntanks,) ndarray or number, default 1.
Scalar ndarray of size (ntanks,) of tank cross-section areas. If scalar, the same area is used for all tanks.
- rhonumber, default 1.
Positive scalar. Density of liquid.
- gnumber, default 9.81
Positive scalar. Gravitational acceleration.
- kwargsany
Keyword arguments passed to PseudoHamiltonianSystem constructor.
Methods
H_tanksystem
dH_tanksystem
pipeflows
tanklevels
- H_tanksystem(x, t=None)
- dH_tanksystem(x, t=None)
- pipeflows(x)
- tanklevels(x)
- phlearn.phsystems.init_msdsystem()
Initialize a standard example of a damped mass-spring system affected by a sine force.
- Returns
- MassSpringDamperSystem
- phlearn.phsystems.init_tanksystem(u=None)
Initialize standard tank system.
- Parameters
- uphlearn.control.PseudoHamiltonianController, defult None
- Returns
- TankSystem
- phlearn.phsystems.init_tanksystem_leaky(nleaks=0)
Initialize tank system with a leaks.
- Parameters
- nleaksint, default 0
If 0, no leaks. If 1, there is a leak on the last tank. If 2, there is a leak on the last and tank number 2.
- Returns
- TankSystem
- phlearn.phsystems.initial_condition_ac(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]))
Creates an initial condition sampler for the Allen-Cahn eqation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and 5.98 with step size 0.02.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_bbm(x=array([0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 8.5, 9., 9.5, 10., 10.5, 11., 11.5, 12., 12.5, 13., 13.5, 14., 14.5, 15., 15.5, 16., 16.5, 17., 17.5, 18., 18.5, 19., 19.5, 20., 20.5, 21., 21.5, 22., 22.5, 23., 23.5, 24., 24.5, 25., 25.5, 26., 26.5, 27., 27.5, 28., 28.5, 29., 29.5, 30., 30.5, 31., 31.5, 32., 32.5, 33., 33.5, 34., 34.5, 35., 35.5, 36., 36.5, 37., 37.5, 38., 38.5, 39., 39.5, 40., 40.5, 41., 41.5, 42., 42.5, 43., 43.5, 44., 44.5, 45., 45.5, 46., 46.5, 47., 47.5, 48., 48.5, 49., 49.5]))
Creates an initial condition sampler for the Benjamin-Bona-Mahony equation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and 49.5 with step size 0.5.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_ch(x=array([0., 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99]))
Creates an initial condition sampler for the Cahn-Hilliard eqation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and .99 with step size 0.01.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_heat(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]))
Creates an initial condition sampler for the heat eqation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and 5.98 with step size 0.02.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_kdv(x=array([0., 0.2, 0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8, 2., 2.2, 2.4, 2.6, 2.8, 3., 3.2, 3.4, 3.6, 3.8, 4., 4.2, 4.4, 4.6, 4.8, 5., 5.2, 5.4, 5.6, 5.8, 6., 6.2, 6.4, 6.6, 6.8, 7., 7.2, 7.4, 7.6, 7.8, 8., 8.2, 8.4, 8.6, 8.8, 9., 9.2, 9.4, 9.6, 9.8, 10., 10.2, 10.4, 10.6, 10.8, 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13., 13.2, 13.4, 13.6, 13.8, 14., 14.2, 14.4, 14.6, 14.8, 15., 15.2, 15.4, 15.6, 15.8, 16., 16.2, 16.4, 16.6, 16.8, 17., 17.2, 17.4, 17.6, 17.8, 18., 18.2, 18.4, 18.6, 18.8, 19., 19.2, 19.4, 19.6, 19.8]), eta=6.0)
Creates an initial condition sampler for the KdV-Burgers equation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and 19.8 with step size 0.2.
- etafloat, optional
The parameter eta in the KdV-Burgers equation. The default is 6.0.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_pm(x=array([0., 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1., 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14, 1.16, 1.18, 1.2, 1.22, 1.24, 1.26, 1.28, 1.3, 1.32, 1.34, 1.36, 1.38, 1.4, 1.42, 1.44, 1.46, 1.48, 1.5, 1.52, 1.54, 1.56, 1.58, 1.6, 1.62, 1.64, 1.66, 1.68, 1.7, 1.72, 1.74, 1.76, 1.78, 1.8, 1.82, 1.84, 1.86, 1.88, 1.9, 1.92, 1.94, 1.96, 1.98, 2., 2.02, 2.04, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.18, 2.2, 2.22, 2.24, 2.26, 2.28, 2.3, 2.32, 2.34, 2.36, 2.38, 2.4, 2.42, 2.44, 2.46, 2.48, 2.5, 2.52, 2.54, 2.56, 2.58, 2.6, 2.62, 2.64, 2.66, 2.68, 2.7, 2.72, 2.74, 2.76, 2.78, 2.8, 2.82, 2.84, 2.86, 2.88, 2.9, 2.92, 2.94, 2.96, 2.98, 3., 3.02, 3.04, 3.06, 3.08, 3.1, 3.12, 3.14, 3.16, 3.18, 3.2, 3.22, 3.24, 3.26, 3.28, 3.3, 3.32, 3.34, 3.36, 3.38, 3.4, 3.42, 3.44, 3.46, 3.48, 3.5, 3.52, 3.54, 3.56, 3.58, 3.6, 3.62, 3.64, 3.66, 3.68, 3.7, 3.72, 3.74, 3.76, 3.78, 3.8, 3.82, 3.84, 3.86, 3.88, 3.9, 3.92, 3.94, 3.96, 3.98, 4., 4.02, 4.04, 4.06, 4.08, 4.1, 4.12, 4.14, 4.16, 4.18, 4.2, 4.22, 4.24, 4.26, 4.28, 4.3, 4.32, 4.34, 4.36, 4.38, 4.4, 4.42, 4.44, 4.46, 4.48, 4.5, 4.52, 4.54, 4.56, 4.58, 4.6, 4.62, 4.64, 4.66, 4.68, 4.7, 4.72, 4.74, 4.76, 4.78, 4.8, 4.82, 4.84, 4.86, 4.88, 4.9, 4.92, 4.94, 4.96, 4.98, 5., 5.02, 5.04, 5.06, 5.08, 5.1, 5.12, 5.14, 5.16, 5.18, 5.2, 5.22, 5.24, 5.26, 5.28, 5.3, 5.32, 5.34, 5.36, 5.38, 5.4, 5.42, 5.44, 5.46, 5.48, 5.5, 5.52, 5.54, 5.56, 5.58, 5.6, 5.62, 5.64, 5.66, 5.68, 5.7, 5.72, 5.74, 5.76, 5.78, 5.8, 5.82, 5.84, 5.86, 5.88, 5.9, 5.92, 5.94, 5.96, 5.98]))
Creates an initial condition sampler for the Perona-Malik eqation.
- Parameters
- xnumpy.ndarray, optional
Spatial grid on which to create the initial conditions. The default is an equidistant grid between 0 and 5.98 with step size 0.02.
- Returns
- callable
A function that takes a numpy random generator as input and returns an initial state on the spatial grid x.
- phlearn.phsystems.initial_condition_radial(r_min, r_max)
Creates an initial condition sampler that draws samples uniformly from the disk r_min <= x^Tx < r_max.
- Returns
- callable
Function taking a numpy random generator and returning an initial state of size 2.
- phlearn.phsystems.zero_force(x, t=None)
A force term that is always zero.
- Parameters
- x(…, N) ndarray
- t(…, 1) ndarray, default None
- Returns
- (…, N) ndarray
All zero ndarray