boost::shared_ptr<AbstractStimulusFunction>  AbstractStimulusFactory<ELEMENT_DIM,SPACE_DIM>::CreateStimulusForNode(Node<SPACE_DIM>* pNode)
{
    //this is the default implementation
    boost::shared_ptr<ZeroStimulus> p_stim (  new ZeroStimulus() );
    return p_stim;
}
    void TestSteadyStateRunnerConverges(void) throw(Exception)
    {
#ifdef CHASTE_CVODE
        //////////// DEFINE PARAMETERS ///////////////
        // Get the frequency
        double hertz = 1.0;

        ///////// END DEFINE PARAMETERS ////////////////////////

        // Setup a CVODE model that has empty solver and stimulus
        boost::shared_ptr<RegularStimulus> p_stimulus;
        boost::shared_ptr<AbstractIvpOdeSolver> p_solver;
        boost::shared_ptr<AbstractCvodeCell> p_model(new CellShannon2004FromCellMLCvode(p_solver, p_stimulus));

        // Get it to use the default stimulus from CellML
        boost::shared_ptr<RegularStimulus> p_reg_stim = p_model->UseCellMLDefaultStimulus();

        { // Test that the steady state analysis throws a nice error if we try to run it with a non-RegularStimulus

            boost::shared_ptr<ZeroStimulus> p_stim(new ZeroStimulus());
            p_model->SetStimulusFunction(p_stim);

            SteadyStateRunner bad_steady_runner(p_model);
            TS_ASSERT_THROWS_THIS(bad_steady_runner.RunToSteadyState(),
                                  "Steady State approximations only work for models with RegularStimulus objects.");

            // Reset to a sensible stimulus function.
            p_model->SetStimulusFunction(p_reg_stim);
        }

        p_reg_stim->SetPeriod(1000.0/hertz);

        // Note that increasing the strictness of the tolerances here (default is 1e-5, 1e-7)
        // actually leads to a faster convergence to steady state, as a model solved in
        // a sloppy way might never actually get close to its true limit cycle!
        p_model->SetTolerances(1e-6,1e-8);

        /**
         * STEADY STATE PACING EXPERIMENT
         */
        /*
         * HOW_TO_TAG Cardiac/Cell Models
         * Get a cardiac cell model to (roughly) a steady state, given a regular stimulus, using the `SteadyStateRunner` class.
         */
        SteadyStateRunner steady_runner(p_model);

        bool result;

        // Here we don't reach steady state by max num paces
        steady_runner.SetMaxNumPaces(1u);
        result = steady_runner.RunToSteadyState();

        TS_ASSERT_EQUALS(result,false);

        // Here we do reach the steady state OK.
        steady_runner.SetMaxNumPaces(10000u);
        result = steady_runner.RunToSteadyState();

        TS_ASSERT_EQUALS(result,true);
        // Your mileage may vary. 32-bit machine, default build gives 520 evaluations, 484 on recent 64-bit CVODE.
        TS_ASSERT_LESS_THAN(steady_runner.GetNumEvaluations(),550u);

        // For coverage
        TS_ASSERT_THROWS_THIS(steady_runner.SetMaxNumPaces(0u),
                "Please set a maximum number of paces that is positive");
#else
        std::cout << "CVODE must be enabled for the steady state runner to work." << std::endl;
#endif //_CHASTE_CVODE
    }