C C There are a total of 4 entries in the algebraic variable array. C There are a total of 2 entries in each of the rate and state variable arrays. C There are a total of 3 entries in the constant variable array. C C C VOI is t in component main (second). C STATES(1) is q_1 in component main (metre). C STATES(2) is v_1 in component main (m_per_s). C ALGBRC(4) is a_1 in component main (m_per_s2). C ALGBRC(1) is u_C in component main (J_per_m). C ALGBRC(2) is u_R in component main (J_per_m). C ALGBRC(3) is u_L in component main (J_per_m). C CONSTS(1) is C in component main (m2_per_J). C CONSTS(2) is R in component main (Js_per_m2). C CONSTS(3) is L in component main (Js2_per_m2). C RATES(1) is d/dt q_1 in component main (metre). C RATES(2) is d/dt v_1 in component main (m_per_s). C SUBROUTINE initConsts(CONSTS, RATES, STATES) REAL CONSTS(*), RATES(*), STATES(*) STATES(1) = 1 STATES(2) = 0 CONSTS(1) = 20 CONSTS(2) = 0.1 CONSTS(3) = 10 RETURN END SUBROUTINE computeRates(VOI, CONSTS, RATES, STATES, ALGBRC) REAL VOI, CONSTS(*), RATES(*), STATES(*), ALGBRC(*) RATES(1) = STATES(2) ALGBRC(1) = STATES(1)/CONSTS(1) ALGBRC(2) = STATES(2)*CONSTS(2) CALL minimize(minfunc_0, CONSTS, VARIABLES, ALGBRC(3)) CALL minimize(minfunc_1, CONSTS, VARIABLES, ALGBRC(4)) RATES(2) = ALGBRC(4) RETURN END SUBROUTINE computeVariables(VOI, CONSTS, RATES, STATES, ALGBRC) REAL VOI, CONSTS(*), RATES(*), STATES(*), ALGBRC(*) ALGBRC(1) = STATES(1)/CONSTS(1) ALGBRC(2) = STATES(2)*CONSTS(2) RETURN END REAL FUNCTION minfunc_0(CONSTS, VARIABLES) REAL CONSTS(*), VARIABLES(*) minfunc_0 = abs(ALGBRC(1) - - ALGBRC(2) - ALGBRC(3)) RETURN END REAL FUNCTION minfunc_1(CONSTS, VARIABLES) REAL CONSTS(*), VARIABLES(*) minfunc_1 = abs(ALGBRC(3) - ALGBRC(4)*CONSTS(3)) RETURN END