Equation(方程) 模块¶
ppsci.equation
¶
PDE
¶
Base class for Partial Differential Equation
Source code in ppsci/equation/pde/base.py
add_equation(name, equation)
¶
Add an equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of equation |
required |
equation |
Callable
|
Computation function for equation. |
required |
create_function(name, invars)
¶
Create named function depending on given invars.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Function name. such as "u", "v", and "f". |
required |
invars |
Tuple[Symbol, ...]
|
List of independent variable of function. |
required |
Returns:
Type | Description |
---|---|
Function
|
sympy.Function: Named sympy function. |
Source code in ppsci/equation/pde/base.py
create_symbols(symbol_str)
¶
Create symbols
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbol_str |
str
|
String contains symbols, such as "x", "x y z". |
required |
Returns:
Type | Description |
---|---|
Union[Symbol, Tuple[Symbol, ...]]
|
Union[sympy.Symbol, Tuple[sympy.Symbol, ...]]: Created symbol(s). |
Source code in ppsci/equation/pde/base.py
parameters()
¶
Return parameters contained in PDE.
Returns:
Type | Description |
---|---|
List[Tensor]
|
List[Tensor]: A list of parameters. |
set_state_dict(state_dict)
¶
FractionalPoisson
¶
Bases: PDE
TODO: refine this docstring Args: alpha (float): Alpha. geom (geometry.Geometry): Computation geometry. resolution (Tuple[int, ...]): Resolution.
Examples:
Source code in ppsci/equation/fpde/fractional_poisson.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
Biharmonic
¶
Bases: PDE
Class for biharmonic equation with supporting special load.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim |
int
|
Dimension of equation. |
required |
q |
Union[float, str, Basic]
|
Load. |
required |
D |
Union[float, str]
|
Rigidity. |
required |
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
Source code in ppsci/equation/pde/biharmonic.py
Laplace
¶
Bases: PDE
Class for laplace equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim |
int
|
Dimension of equation. |
required |
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
Source code in ppsci/equation/pde/laplace.py
LinearElasticity
¶
Bases: PDE
Linear elasticity equations. Use either (E, nu) or (lambda_, mu) to define the material properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E |
Optional[Union[float, str]]
|
The Young's modulus. Defaults to None. |
None
|
nu |
Optional[Union[float, str]]
|
The Poisson's ratio. Defaults to None. |
None
|
lambda_ |
Optional[Union[float, str]]
|
Lamé's first parameter. Defaults to None. |
None
|
mu |
Optional[Union[float, str]]
|
Lamé's second parameter (shear modulus). Defaults to None. |
None
|
rho |
Union[float, str]
|
Mass density. Defaults to 1. |
1
|
dim |
int
|
Dimension of the linear elasticity (2 or 3). Defaults to 3. |
3
|
time |
bool
|
Whether contains time data. Defaults to False. |
False
|
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
>>> import ppsci
>>> pde = ppsci.equation.LinearElasticity(
... E=None, nu=None, lambda_=1e4, mu=100, dim=3
... )
Source code in ppsci/equation/pde/linear_elasticity.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
NavierStokes
¶
Bases: PDE
Class for navier-stokes equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nu |
Union[float, str]
|
Dynamic viscosity. |
required |
rho |
Union[float, str]
|
Density. |
required |
dim |
int
|
Dimension of equation. |
required |
time |
bool
|
Whether the equation is time-dependent. |
required |
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
Source code in ppsci/equation/pde/navier_stokes.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
NormalDotVec
¶
Bases: PDE
Normal Dot Vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vec_keys |
Tuple[str, ...]
|
Keys for vectors, such as ("u", "v", "w") for velocity vector. |
required |
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
Source code in ppsci/equation/pde/normal_dot_vec.py
Poisson
¶
Bases: PDE
Class for poisson equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim |
int
|
Dimension of equation. |
required |
detach_keys |
Optional[Tuple[str, ...]]
|
Keys used for detach during computing. Defaults to None. |
None
|
Examples:
Source code in ppsci/equation/pde/poisson.py
Vibration
¶
Bases: PDE
Vortex induced vibration equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rho |
float
|
Generalized mass. |
required |
k1 |
float
|
Learnable parameter for modal damping. |
required |
k2 |
float
|
Learnable parameter for generalized stiffness. |
required |
Examples:
Source code in ppsci/equation/pde/viv.py
Volterra
¶
Bases: PDE
A second kind of volterra integral equation with Gaussian quadrature algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bound |
float
|
Lower bound |
required |
num_points |
int
|
Sampled points in integral interval. |
required |
quad_deg |
int
|
Number of quadrature. |
required |
kernel_func |
Callable
|
Kernel func |
required |
func |
Callable
|
|
required |
Examples:
>>> import ppsci
>>> import numpy as np
>>> vol_eq = ppsci.equation.Volterra(
... 0, 12, 20, lambda t, s: np.exp(s - t), lambda out: out["u"],
... )
Source code in ppsci/equation/ide/volterra.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
get_quad_points(t)
¶
Scale and transform quad_x from [-1, 1] to range [a, b]. reference: https://en.wikipedia.org/wiki/Gaussian_quadrature#Change_of_interval
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
Tensor
|
Tensor array of upper bounds 't' for integral. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
paddle.Tensor: Transformed points in desired range with shape of [N, Q]. |
Source code in ppsci/equation/ide/volterra.py
创建日期: November 6, 2023