Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
HeartConfigDefaults.hpp
Go to the documentation of this file.
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef HEARTCONFIGDEFAULTS_HPP_
37#define HEARTCONFIGDEFAULTS_HPP_
38
90boost::shared_ptr<cp::chaste_parameters_type> CreateDefaultParameters()
91{
92 // Simulation parameters
93 cp::simulation_type simulation_params;
94 simulation_params.SpaceDimension().set(3);
95 cp::domain_type domain("Mono");
96 simulation_params.Domain().set(domain);
97 cp::ionic_model_selection_type default_ionic_model;
98 cp::ionic_models_available_type ionic_model("LuoRudyI");
99 default_ionic_model.Hardcoded().set(ionic_model);
100 cp::ionic_models_type ionic_models(default_ionic_model);
101 simulation_params.IonicModels().set(ionic_models);
102 simulation_params.OutputDirectory().set("ChasteResults");
103 simulation_params.OutputFilenamePrefix().set("SimulationResults");
104
105 // Physiological parameters
106 cp::physiological_type phys_params;
107 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, intra_conductivities,
108 1.75, 1.75, 1.75, "mS/cm");
109 phys_params.IntracellularConductivities().set(intra_conductivities);
110 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, extra_conductivities,
111 7.0, 7.0, 7.0, "mS/cm");
112 phys_params.ExtracellularConductivities().set(extra_conductivities);
113 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, bath_conductivity, 7.0, "mS/cm");
114 phys_params.BathConductivity().set(bath_conductivity);
115 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, surface_area_to_volume_ratio, 1400, "1/cm");
116 phys_params.SurfaceAreaToVolumeRatio().set(surface_area_to_volume_ratio);
117 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, capacitance, 1.0, "uF/cm^2");
118 phys_params.Capacitance().set(capacitance);
119
120 cp::purkinje_physiological_type purkinje_phys_params;
121 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, purkinje_Am, 2800, "1/cm");
122 purkinje_phys_params.SurfaceAreaToVolumeRatio().set(purkinje_Am);
123 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, purkinje_Cm, 1.0, "uF/cm^2");
124 purkinje_phys_params.Capacitance().set(purkinje_Cm);
125 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, purkinje_conductivity, 1.75, "mS/cm");
126 purkinje_phys_params.Conductivity().set(purkinje_conductivity);
127 phys_params.Purkinje().set(purkinje_phys_params);
128
129 // Numerical parameters
130 cp::numerical_type numerical_params;
131 XSD_CREATE_WITH_FIXED_ATTR3(cp::time_steps_type, timesteps, 0.01, 0.01, 0.01, "ms");
132 cp::ksp_tolerances_type tolerances;
133 tolerances.KSPAbsolute().set(2e-4);
134 cp::ksp_solver_type ksp_solver("cg");
135 cp::ksp_preconditioner_type ksp_precond("bjacobi");
136 cp::mesh_partitioning_type mesh_partitioning("parmetis");
137 numerical_params.TimeSteps().set(timesteps);
138 numerical_params.KSPTolerances().set(tolerances);
139 numerical_params.KSPSolver().set(ksp_solver);
140 numerical_params.KSPPreconditioner().set(ksp_precond);
141 numerical_params.MeshPartitioning().set(mesh_partitioning);
142 numerical_params.UseStateVariableInterpolation().set(cp::yesno_type::no);
143
144 // Postprocessing - empty is equivalent to missing, so don't include it
145 //cp::postprocessing_type postproc;
146
147 // Full default parameters
148 boost::shared_ptr<cp::chaste_parameters_type> p_defaults(new cp::chaste_parameters_type(phys_params, numerical_params));
149 p_defaults->Simulation().set(simulation_params);
150 //p_defaults->PostProcessing().set(postproc);
151 return p_defaults;
152}
153
154
161#define MERGE_PARAM(path) \
162 if (!pParams->path().present()) { \
163 if (pDefaults->path().present()) { \
164 pParams->path().set(pDefaults->path().get()); \
165 } \
166 }
172#define ELSE_IF_DEFAULT(path) \
173 else if (pDefaults->path().present())
174
184void MergeDefaults(boost::shared_ptr<cp::chaste_parameters_type> pParams,
185 boost::shared_ptr<cp::chaste_parameters_type> pDefaults)
186{
187 // Simulation and ResumeSimulation are mutually exclusive
188 if (!pParams->ResumeSimulation().present())
189 {
190 MERGE_PARAM(Simulation)
191 ELSE_IF_DEFAULT(Simulation) // Simulation() exists in both
192 {
193 MERGE_PARAM(Simulation()->SpaceDimension)
194 MERGE_PARAM(Simulation()->Domain)
195 MERGE_PARAM(Simulation()->IonicModels)
196 ELSE_IF_DEFAULT(Simulation()->IonicModels) // Simulation()->IonicModels() exists in both
197 {
198 //MERGE_PARAM(Simulation()->IonicModels()->Default) // This must be present if IonicModels is
199 }
200 MERGE_PARAM(Simulation()->OutputDirectory)
201 MERGE_PARAM(Simulation()->OutputFilenamePrefix)
202 }
203
204 // Physiological() is mandatory
205 //MERGE_PARAM(Physiological)
206 //ELSE_IF_DEFAULT(Physiological) // Physiological() exists in both
207 {
208 MERGE_PARAM(Physiological().IntracellularConductivities)
209 MERGE_PARAM(Physiological().ExtracellularConductivities)
210 MERGE_PARAM(Physiological().BathConductivity)
211 MERGE_PARAM(Physiological().SurfaceAreaToVolumeRatio)
212 MERGE_PARAM(Physiological().Capacitance)
213 MERGE_PARAM(Physiological().Purkinje)
214 ELSE_IF_DEFAULT(Physiological().Purkinje) // Physiological()->Purkinje() exists in both
215 {
216 MERGE_PARAM(Physiological().Purkinje()->SurfaceAreaToVolumeRatio)
217 MERGE_PARAM(Physiological().Purkinje()->Capacitance)
218 MERGE_PARAM(Physiological().Purkinje()->Conductivity)
219 }
220 }
221
222 // Numerical() is mandatory
223 //MERGE_PARAM(Numerical)
224 //ELSE_IF_DEFAULT(Numerical) // Numerical() exists in both
225 {
226 MERGE_PARAM(Numerical().TimeSteps)
227 MERGE_PARAM(Numerical().KSPTolerances)
228 ELSE_IF_DEFAULT(Numerical().KSPTolerances) // Numerical()->KSPTolerances() exists in both
229 {
230 // Note that we aren't allowed both absolute and relative tolerances
231 if (!pParams->Numerical().KSPTolerances()->KSPRelative().present())
232 {
233 MERGE_PARAM(Numerical().KSPTolerances()->KSPAbsolute)
234 }
235 }
236 MERGE_PARAM(Numerical().KSPSolver)
237 MERGE_PARAM(Numerical().KSPPreconditioner)
238 MERGE_PARAM(Numerical().MeshPartitioning)
239 MERGE_PARAM(Numerical().UseStateVariableInterpolation)
240 }
241 }
242}
243
244#endif /*HEARTCONFIGDEFAULTS_HPP_*/
void MergeDefaults(boost::shared_ptr< cp::chaste_parameters_type > pParams, boost::shared_ptr< cp::chaste_parameters_type > pDefaults)
boost::shared_ptr< cp::chaste_parameters_type > CreateDefaultParameters()
#define ELSE_IF_DEFAULT(path)
#define MERGE_PARAM(path)