@@ -43,13 +43,23 @@ def __init__(self):
43
43
def create_symbols (
44
44
symbol_str : str ,
45
45
) -> Union [sympy .Symbol , Tuple [sympy .Symbol , ...]]:
46
- """Create symbols
46
+ """create symbolic variables.
47
47
48
48
Args:
49
49
symbol_str (str): String contains symbols, such as "x", "x y z".
50
50
51
51
Returns:
52
52
Union[sympy.Symbol, Tuple[sympy.Symbol, ...]]: Created symbol(s).
53
+
54
+ Examples:
55
+ >>> import ppsci
56
+ >>> pde = ppsci.equation.PDE()
57
+ >>> symbol_x = pde.create_symbols('x')
58
+ >>> symbols_xyz = pde.create_symbols('x y z')
59
+ >>> print(symbol_x)
60
+ x
61
+ >>> print(symbols_xyz)
62
+ (x, y, z)
53
63
"""
54
64
return sympy .symbols (symbol_str )
55
65
@@ -64,6 +74,17 @@ def create_function(
64
74
65
75
Returns:
66
76
sympy.Function: Named sympy function.
77
+
78
+ Examples:
79
+ >>> import ppsci
80
+ >>> pde = ppsci.equation.PDE()
81
+ >>> x, y, z = pde.create_symbols('x y z')
82
+ >>> u = pde.create_function('u', (x, y))
83
+ >>> f = pde.create_function('f', (x, y, z))
84
+ >>> print(u)
85
+ u(x, y)
86
+ >>> print(f)
87
+ f(x, y, z)
67
88
"""
68
89
expr = sympy .Function (name )(* invars )
69
90
@@ -79,6 +100,17 @@ def add_equation(self, name: str, equation: Callable):
79
100
Args:
80
101
name (str): Name of equation
81
102
equation (Callable): Computation function for equation.
103
+
104
+ Examples:
105
+ >>> import ppsci
106
+ >>> import sympy
107
+ >>> pde = ppsci.equation.PDE()
108
+ >>> x, y = pde.create_symbols('x y')
109
+ >>> u = x**2 + y**2
110
+ >>> equation = sympy.diff(u, x) + sympy.diff(u, y)
111
+ >>> pde.add_equation('linear_pde', equation)
112
+ >>> print(pde)
113
+ PDE, linear_pde: 2*x + 2*y
82
114
"""
83
115
self .equations .update ({name : equation })
84
116
0 commit comments