void AbstractParameterisedSystem<VECTOR>::CheckParametersOnLoad(const std::vector<double>& rParameters, const std::vector<std::string>& rParameterNames)
{
    if (GetVectorSize(mParameters) != rGetParameterNames().size())
    {
        // Subclass constructor didn't give default values, so we need the archive to provide them all
        if (rParameterNames.size() != rGetParameterNames().size())
        {
            EXCEPTION("Number of ODE parameters in archive does not match number in class.");
        }
        CreateVectorIfEmpty(mParameters,rGetParameterNames().size());
    }

    // Check whether the archive specifies parameters that don't appear in this class,
    // and create a map from archive index to local index
    std::vector<unsigned> index_map(rParameterNames.size());
    for (unsigned i=0; i<rParameterNames.size(); ++i)
    {
        index_map[i] = find(rGetParameterNames().begin(), rGetParameterNames().end(), rParameterNames[i])
                       - rGetParameterNames().begin();
        if (index_map[i] == rGetParameterNames().size())
        {
            EXCEPTION("Archive specifies a parameter '" + rParameterNames[i] + "' which does not appear in this class.");
        }
    }

    for (unsigned i=0; i<rParameterNames.size(); ++i)
    {
        SetVectorComponent(mParameters,index_map[i],rParameters[i]);
    }

    // Paranoia check
    assert(GetVectorSize(mParameters) == rGetParameterNames().size());
}
Beispiel #2
0
    void save(Archive & archive, const unsigned int version) const
    {
        // Despite the fact that 3 of these variables actually live in our base class,
        // we still archive them here to maintain backwards compatibility.
        // Since the N_Vector version of mStateVariables and mParameters needs converting
        // to a standard vector before archiving, this doesn't hurt too much.
        archive & mNumberOfStateVariables;
        archive & mUseAnalyticJacobian;
        archive & mStateVariables;
        archive & mParameters;

        if (version > 0)
        {
            archive & rGetParameterNames();
        }

        // This is always set up by subclass constructors, and is essentially
        // 'static' data, so shouldn't go in the archive.
        //archive &mpSystemInfo;
    }
void AbstractCardiacCell::Init()
{
    ResetToInitialConditions();
    mParameters.resize(rGetParameterNames().size());
}