MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / add_equation

Method add_equation

dedalus/core/problems.py:65–94  ·  view source on GitHub ↗

Add equation to problem.

(self, equation, condition="True")

Source from the content-addressed store, hash-verified

63 return np.result_type(*[eqn['dtype'] for eqn in self.equations])
64
65 def add_equation(self, equation, condition="True"):
66 """Add equation to problem."""
67 logger.debug(f"Adding equation {len(self.eqs)}")
68 # Split equation into LHS and RHS expressions
69 if isinstance(equation, str):
70 # Parse string-valued equations
71 namespace = dict(self.namespace)
72 LHS_str, RHS_str = parsing.split_equation(equation)
73 LHS = eval(LHS_str, namespace)
74 RHS = eval(RHS_str, namespace)
75 else:
76 # Split operator tuples
77 LHS, RHS = equation
78 logger.debug(f" LHS: {LHS}")
79 logger.debug(f" RHS: {RHS}")
80 logger.debug(f" condition: {condition}")
81 # Build basic equation dictionary
82 # Note: domain determined after NCC reinitialization
83 expr = LHS - RHS
84 eqn = {'eqn': expr,
85 'LHS': LHS,
86 'RHS': RHS,
87 'condition': condition,
88 'tensorsig': expr.tensorsig,
89 'dtype': expr.dtype,
90 'valid_modes': expr.valid_modes.copy()}
91 self._check_equation_conditions(eqn)
92 self._build_matrix_expressions(eqn)
93 self.equations.append(eqn)
94 return eqn
95
96 def build_solver(self, *args, **kw):
97 """Build corresponding solver class."""

Callers 15

kdv_burgers.pyFile · 0.80
shear_flow.pyFile · 0.80
max_growth_rateFunction · 0.80
pipe_flow.pyFile · 0.80
mathieu_evp.pyFile · 0.80
poisson.pyFile · 0.80
shallow_water.pyFile · 0.80
rayleigh_benard.pyFile · 0.80

Calls 3

copyMethod · 0.80

Tested by 15

test_cartesian_outputFunction · 0.64
test_heat_periodicFunction · 0.64
test_cartesian_outputFunction · 0.64
test_polar_outputFunction · 0.64
test_spherical_outputFunction · 0.64
test_skew_implicitFunction · 0.64