Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #ifndef HEARTCONFIGDEFAULTS_HPP_ 00037 #define HEARTCONFIGDEFAULTS_HPP_ 00038 00090 boost::shared_ptr<cp::chaste_parameters_type> CreateDefaultParameters() 00091 { 00092 // Simulation parameters 00093 cp::simulation_type simulation_params; 00094 simulation_params.SpaceDimension().set(3); 00095 cp::domain_type domain("Mono"); 00096 simulation_params.Domain().set(domain); 00097 cp::ionic_model_selection_type default_ionic_model; 00098 cp::ionic_models_available_type ionic_model("LuoRudyI"); 00099 default_ionic_model.Hardcoded().set(ionic_model); 00100 cp::ionic_models_type ionic_models(default_ionic_model); 00101 simulation_params.IonicModels().set(ionic_models); 00102 simulation_params.OutputDirectory().set("ChasteResults"); 00103 simulation_params.OutputFilenamePrefix().set("SimulationResults"); 00104 00105 // Physiological parameters 00106 cp::physiological_type phys_params; 00107 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, intra_conductivities, 00108 1.75, 1.75, 1.75, "mS/cm"); 00109 phys_params.IntracellularConductivities().set(intra_conductivities); 00110 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, extra_conductivities, 00111 7.0, 7.0, 7.0, "mS/cm"); 00112 phys_params.ExtracellularConductivities().set(extra_conductivities); 00113 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, bath_conductivity, 7.0, "mS/cm"); 00114 phys_params.BathConductivity().set(bath_conductivity); 00115 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, surface_area_to_volume_ratio, 1400, "1/cm"); 00116 phys_params.SurfaceAreaToVolumeRatio().set(surface_area_to_volume_ratio); 00117 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, capacitance, 1.0, "uF/cm^2"); 00118 phys_params.Capacitance().set(capacitance); 00119 00120 cp::purkinje_physiological_type purkinje_phys_params; 00121 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, purkinje_Am, 2800, "1/cm"); 00122 purkinje_phys_params.SurfaceAreaToVolumeRatio().set(purkinje_Am); 00123 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, purkinje_Cm, 1.0, "uF/cm^2"); 00124 purkinje_phys_params.Capacitance().set(purkinje_Cm); 00125 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, purkinje_conductivity, 1.75, "mS/cm"); 00126 purkinje_phys_params.Conductivity().set(purkinje_conductivity); 00127 phys_params.Purkinje().set(purkinje_phys_params); 00128 00129 // Numerical parameters 00130 cp::numerical_type numerical_params; 00131 XSD_CREATE_WITH_FIXED_ATTR3(cp::time_steps_type, timesteps, 0.01, 0.01, 0.01, "ms"); 00132 cp::ksp_tolerances_type tolerances; 00133 tolerances.KSPAbsolute().set(2e-4); 00134 cp::ksp_solver_type ksp_solver("cg"); 00135 cp::ksp_preconditioner_type ksp_precond("bjacobi"); 00136 cp::mesh_partitioning_type mesh_partitioning("metis"); 00137 numerical_params.TimeSteps().set(timesteps); 00138 numerical_params.KSPTolerances().set(tolerances); 00139 numerical_params.KSPSolver().set(ksp_solver); 00140 numerical_params.KSPPreconditioner().set(ksp_precond); 00141 numerical_params.MeshPartitioning().set(mesh_partitioning); 00142 numerical_params.UseStateVariableInterpolation().set(cp::yesno_type::no); 00143 00144 // Postprocessing - empty is equivalent to missing, so don't include it 00145 //cp::postprocessing_type postproc; 00146 00147 // Full default parameters 00148 boost::shared_ptr<cp::chaste_parameters_type> p_defaults(new cp::chaste_parameters_type(phys_params, numerical_params)); 00149 p_defaults->Simulation().set(simulation_params); 00150 //p_defaults->PostProcessing().set(postproc); 00151 return p_defaults; 00152 } 00153 00154 00161 #define MERGE_PARAM(path) \ 00162 if (!pParams->path().present()) { \ 00163 if (pDefaults->path().present()) { \ 00164 pParams->path().set(pDefaults->path().get()); \ 00165 } \ 00166 } 00167 00172 #define ELSE_IF_DEFAULT(path) \ 00173 else if (pDefaults->path().present()) 00174 00184 void MergeDefaults(boost::shared_ptr<cp::chaste_parameters_type> pParams, 00185 boost::shared_ptr<cp::chaste_parameters_type> pDefaults) 00186 { 00187 // Simulation and ResumeSimulation are mutually exclusive 00188 if (!pParams->ResumeSimulation().present()) 00189 { 00190 MERGE_PARAM(Simulation) 00191 ELSE_IF_DEFAULT(Simulation) // Simulation() exists in both 00192 { 00193 MERGE_PARAM(Simulation()->SpaceDimension) 00194 MERGE_PARAM(Simulation()->Domain) 00195 MERGE_PARAM(Simulation()->IonicModels) 00196 ELSE_IF_DEFAULT(Simulation()->IonicModels) // Simulation()->IonicModels() exists in both 00197 { 00198 //MERGE_PARAM(Simulation()->IonicModels()->Default) // This must be present if IonicModels is 00199 } 00200 MERGE_PARAM(Simulation()->OutputDirectory) 00201 MERGE_PARAM(Simulation()->OutputFilenamePrefix) 00202 } 00203 00204 // Physiological() is mandatory 00205 //MERGE_PARAM(Physiological) 00206 //ELSE_IF_DEFAULT(Physiological) // Physiological() exists in both 00207 { 00208 MERGE_PARAM(Physiological().IntracellularConductivities) 00209 MERGE_PARAM(Physiological().ExtracellularConductivities) 00210 MERGE_PARAM(Physiological().BathConductivity) 00211 MERGE_PARAM(Physiological().SurfaceAreaToVolumeRatio) 00212 MERGE_PARAM(Physiological().Capacitance) 00213 MERGE_PARAM(Physiological().Purkinje) 00214 ELSE_IF_DEFAULT(Physiological().Purkinje) // Physiological()->Purkinje() exists in both 00215 { 00216 MERGE_PARAM(Physiological().Purkinje()->SurfaceAreaToVolumeRatio) 00217 MERGE_PARAM(Physiological().Purkinje()->Capacitance) 00218 MERGE_PARAM(Physiological().Purkinje()->Conductivity) 00219 } 00220 } 00221 00222 // Numerical() is mandatory 00223 //MERGE_PARAM(Numerical) 00224 //ELSE_IF_DEFAULT(Numerical) // Numerical() exists in both 00225 { 00226 MERGE_PARAM(Numerical().TimeSteps) 00227 MERGE_PARAM(Numerical().KSPTolerances) 00228 ELSE_IF_DEFAULT(Numerical().KSPTolerances) // Numerical()->KSPTolerances() exists in both 00229 { 00230 // Note that we aren't allowed both absolute and relative tolerances 00231 if (!pParams->Numerical().KSPTolerances()->KSPRelative().present()) 00232 { 00233 MERGE_PARAM(Numerical().KSPTolerances()->KSPAbsolute) 00234 } 00235 } 00236 MERGE_PARAM(Numerical().KSPSolver) 00237 MERGE_PARAM(Numerical().KSPPreconditioner) 00238 MERGE_PARAM(Numerical().MeshPartitioning) 00239 MERGE_PARAM(Numerical().UseStateVariableInterpolation) 00240 } 00241 } 00242 } 00243 00244 #endif /*HEARTCONFIGDEFAULTS_HPP_*/