/* Copyright (c) 2005-2014, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TESTSTANDINGWAVE_HPP_ #define TESTSTANDINGWAVE_HPP_ #include #include "BidomainProblem.hpp" #include "DistributedTetrahedralMesh.hpp" #include "PetscSetupAndFinalize.hpp" #include "AbstractCardiacCellFactory.hpp" #include "RegularStimulus.hpp" #include "li_mouse_2010Cvode.hpp" #ifdef CHASTE_CVODE class MouseCellFactory : public AbstractCardiacCellFactory<2> { private: boost::shared_ptr mpStimulus; public: MouseCellFactory(const double& rPeriod) : AbstractCardiacCellFactory<2>(), mpStimulus(new RegularStimulus(-40000.0, 2, rPeriod, 10)) { } AbstractCardiacCellInterface* CreateCardiacCellForTissueNode(Node<2u>* pNode) { AbstractCardiacCellInterface* p_cell; boost::shared_ptr p_empty_solver; const double x = pNode->rGetLocation()[0]; //const double y = pNode->rGetLocation()[1]; if ( (x<0.05+1e-6) ) // Left hand edge { p_cell = new Cellli_mouse_2010FromCellMLCvode(p_empty_solver, mpStimulus); } else { p_cell = new Cellli_mouse_2010FromCellMLCvode(p_empty_solver, this->mpZeroStimulus); } return p_cell; } }; #endif // CHASTE_CVODE class TestStandingWave: public CxxTest::TestSuite { public: void TestBasic2dPropagation() throw (Exception) { #ifdef CHASTE_CVODE /** * SET OPTIONS FOR THIS RUN */ double pacing_cycle_length = 45; double end_time = 260; /** * SET UP MESH */ DistributedTetrahedralMesh<2,2> mesh; double h=0.01; double region_width = 0.5; mesh.ConstructRegularSlabMesh(h, 2.0*region_width, 0.5*region_width); /** * SET STANDARD OPTIONS */ HeartConfig::Instance()->SetSimulationDuration(end_time); //ms HeartConfig::Instance()->SetOutputDirectory("StandingWave"); HeartConfig::Instance()->SetOutputFilenamePrefix("results"); HeartConfig::Instance()->SetVisualizeWithVtk(true); HeartConfig::Instance()->SetVisualizeWithMeshalyzer(false); /** * NUMERICAL METHOD PARAMETERS */ HeartConfig::Instance()->SetOdePdeAndPrintingTimeSteps(0.1, 0.1, 0.1); /* * SET UP HETEROGENEOUS CONDUCTIVITY */ const double intra_conductivity = 1.75; // Chaste Defaults const double extra_conductivity = 7.0; // Chaste Defaults // Elsewhere we use the defaults. HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(intra_conductivity, intra_conductivity)); HeartConfig::Instance()->SetExtracellularConductivities(Create_c_vector(extra_conductivity, extra_conductivity)); { // Interrogate a model to get all the state variables boost::shared_ptr p_stimulus; boost::shared_ptr p_solver; Cellli_mouse_2010FromCellMLCvode cell(p_solver, p_stimulus); // Copy all the state variable names from the temporary cell into // HeartConfig so that they are all printed out to HDF5 HeartConfig::Instance()->SetOutputVariables( cell.rGetStateVariableNames() ); } /** * COMPLETE THE SET UP OF PROBLEM */ // Make a cell factory MouseCellFactory cell_factory(pacing_cycle_length); BidomainProblem<2> problem( &cell_factory ); problem.SetMesh( &mesh ); problem.SetWriteInfo(); // Writes max and min voltages through time to std::cout. problem.Initialise(); problem.Solve(); #else std::cout << "CVODE is not installed, or CHASTE is not configured to use it, check your hostconfig settings." << std::endl; TS_ASSERT(false); #endif // CHASTE_CVODE } }; #endif // TESTSTANDINGWAVE_HPP_