def _create_ode_solver(self): """Helper function to initialize a suitable ODE solver from the cardiac model.""" # Extract cardiac cell model from cardiac model cell_model = self._model.cell_models() # Extract stimulus from the cardiac model(!) if self.parameters['apply_stimulus_current_to_pde']: stimulus = None else: stimulus = self._model.stimulus() # Extract ode solver parameters params = self.parameters["BasicCardiacODESolver"] # Propagate enable_adjoint to Bidomain solver if params.has_parameter("enable_adjoint"): params["enable_adjoint"] = self.parameters["enable_adjoint"] solver = BasicCardiacODESolver(self._heart_mesh, self._time, cell_model, I_s=stimulus, params=params) return solver
def default_parameters(): """Initialize and return a set of default parameters for the splitting solver *Returns* A set of parameters (:py:class:`dolfin.Parameters`) To inspect all the default parameters, do:: info(BasicSplittingSolver.default_parameters(), True) """ params = Parameters("BasicSplittingSolver") params.add("enable_adjoint", True) params.add("theta", 0.5, 0., 1.) params.add("apply_stimulus_current_to_pde", False) try: params.add("pde_solver", "bidomain", set(["bidomain"])) except: params.add("pde_solver", "bidomain", ["bidomain"]) pass # Add default parameters from ODE solver, but update for V # space ode_solver_params = BasicCardiacODESolver.default_parameters() ode_solver_params["V_polynomial_degree"] = 1 ode_solver_params["V_polynomial_family"] = "CG" params.add(ode_solver_params) pde_solver_params = BasicBidomainSolver.default_parameters() pde_solver_params["polynomial_degree"] = 1 params.add(pde_solver_params) return params
def default_parameters(): """Initialize and return a set of default parameters for the splitting solver *Returns* The set of default parameters (:py:class:`dolfin.Parameters`) *Example of usage*:: info(SplittingSolver.default_parameters(), True) """ params = Parameters("SplittingSolver") params.add("enable_adjoint", True) params.add("theta", 0.5, 0, 1) params.add("apply_stimulus_current_to_pde", False) try: params.add("pde_solver", "bidomain", set(["bidomain", "monodomain"])) params.add("ode_solver_choice", "CardiacODESolver", set(["BasicCardiacODESolver", "CardiacODESolver"])) except: params.add("pde_solver", "bidomain", ["bidomain", "monodomain"]) params.add("ode_solver_choice", "CardiacODESolver", ["BasicCardiacODESolver", "CardiacODESolver"]) pass # Add default parameters from ODE solver ode_solver_params = CardiacODESolver.default_parameters() ode_solver_params["scheme"] = "RL1" params.add(ode_solver_params) # Add default parameters from ODE solver basic_ode_solver_params = BasicCardiacODESolver.default_parameters() basic_ode_solver_params["V_polynomial_degree"] = 1 basic_ode_solver_params["V_polynomial_family"] = "CG" params.add(basic_ode_solver_params) pde_solver_params = BidomainSolver.default_parameters() pde_solver_params["polynomial_degree"] = 1 params.add(pde_solver_params) pde_solver_params = MonodomainSolver.default_parameters() pde_solver_params["polynomial_degree"] = 1 params.add(pde_solver_params) return params