    
    void {{class_name}}::VerifyStateVariables()
    {
        {{vector_decl}} rY = rGetStateVariables();
        {%- if use_verify_state_variables %}{% for state_var in state_vars %}
        {%- if state_var.range_low != '' or  state_var.range_high != '' %}double {{ state_var.var }} = {{state_var.rY_lookup}};
        // Units: {{state_var.units}}; Initial value: {{state_var.initial_value}}
        {% endif %}{%- endfor %}
        {% for state_var in state_vars %}
        {%- if state_var.range_low != '' or  state_var.range_high != '' %}if ({%- if state_var.range_low != '' %}{{ state_var.var }} < {{ state_var.range_low }}{% endif %}{%- if state_var.range_low != '' and  state_var.range_high != '' %} || {% endif %}{%- if state_var.range_high != '' %}{{ state_var.var }} > {{ state_var.range_high }}{% endif %})
        {
            EXCEPTION(DumpState("State variable {{ state_var.annotated_var_name }} has gone out of range. Check numerical parameters, for example time and space stepsizes, and/or solver tolerances"));
        }
        {% endif %}{%- endfor %}{% endif%}
        std::string error_message = "";
        {% for state_var in state_vars %}{%if loop.last%}
        for (unsigned i=0; i < {{state_vars|length}}; i++)
        {
            if(std::isnan({{ state_var.rY_lookup|replace(loop.index0, "i")  }}))
            {
                error_message += "State variable " + this->rGetStateVariableNames()[i] + " is not a number\n";
            }
            if(std::isinf({{ state_var.rY_lookup|replace(loop.index0, "i")  }}))
            {
                error_message += "State variable " + this->rGetStateVariableNames()[i] + " has become INFINITE\n";
            }
            if(this->is_concentration[i] && {{ state_var.rY_lookup|replace(loop.index0, "i")  }} < 0)
            {
                error_message += "Concentration " + this->rGetStateVariableNames()[i] + " below 0\n";
            }
            if(this->is_probability[i] && {{ state_var.rY_lookup|replace(loop.index0, "i")  }} < 0)
            {
                error_message += "Probability " + this->rGetStateVariableNames()[i] + " below 0\n";
            }
            if(this->is_probability[i] && {{ state_var.rY_lookup|replace(loop.index0, "i")  }} > 1)
            {
                error_message += "Probability " + this->rGetStateVariableNames()[i] + " above 1\n";
            }
        }
        {%-endif%}{%- endfor %}
        if (error_message != ""){
            EXCEPTION(DumpState(error_message));
        }
    }
