Trouble Replicating a Do Loop Structure
Posted: Sat Jun 06, 2009 3:08 am
I am trying to convert an existing program and have the following Revolution function.
function s1_pT p, T
--
--Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam, September 1997
--5 Equations for Region 1, Section. 5.1 Basic Equation
--Eqution 7, Table 3, Page 6
--
put 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 into I1
put -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 into J1
put 0.14632971213167, -0.84548187169114, -3.756360367204, 3.3855169168385, -0.95791963387872, 0.15772038513228, -0.016616417199501, 8.1214629983568E-04, 2.8319080123804E-04, -6.0706301565874E-04, -0.018990068218419, -0.032529748770505, -0.021841717175414, -5.283835796993E-05, -4.7184321073267E-04, -3.0001780793026E-04, 4.7661393906987E-05, -4.4141845330846E-06, -7.2694996297594E-16, -3.1679644845054E-05, -2.8270797985312E-06, -8.5205128120103E-10, -2.2425281908E-06, -6.5171222895601E-07, -1.4341729937924E-13, -4.0516996860117E-07, -1.2734301741641E-09, -1.7424871230634E-10, -6.8762131295531E-19, 1.4478307828521E-20, 2.6335781662795E-23, -1.1947622640071E-23, 1.8228094581404E-24, -9.3537087292458E-26 into n1
put 0.461526 into R --kJ/(kg K)
put p / 16.53 into myPi
put 1386 / T into tau
put 0 into gamma
put 0 into gamma_der_tau
repeat with i = 1 to 34
put gamma_der_tau + (n1 * (7.1 - myPi) ^ I1 * J1 * (tau - 1.222) ^ (J1 - 1)) into gamma_der_tau
put gamma + n1 * (7.1 - myPi) ^ I1 * (tau - 1.222) ^ J1 into gamma
end repeat
put R * tau * gamma_der_tau - R * gamma into s1_pT
return s1_pT
end s1_pT
The problem I'm seeing is that the variables gamma and gamma-der_tau never change from the initialized zero value.
Can anyone tell me why? Is there a problem with my use of the 'repeat' control structure, or is the problem with the way I've initialized my arrays? Is the first array index 0 or 1? Something else????
function s1_pT p, T
--
--Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam, September 1997
--5 Equations for Region 1, Section. 5.1 Basic Equation
--Eqution 7, Table 3, Page 6
--
put 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 into I1
put -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 into J1
put 0.14632971213167, -0.84548187169114, -3.756360367204, 3.3855169168385, -0.95791963387872, 0.15772038513228, -0.016616417199501, 8.1214629983568E-04, 2.8319080123804E-04, -6.0706301565874E-04, -0.018990068218419, -0.032529748770505, -0.021841717175414, -5.283835796993E-05, -4.7184321073267E-04, -3.0001780793026E-04, 4.7661393906987E-05, -4.4141845330846E-06, -7.2694996297594E-16, -3.1679644845054E-05, -2.8270797985312E-06, -8.5205128120103E-10, -2.2425281908E-06, -6.5171222895601E-07, -1.4341729937924E-13, -4.0516996860117E-07, -1.2734301741641E-09, -1.7424871230634E-10, -6.8762131295531E-19, 1.4478307828521E-20, 2.6335781662795E-23, -1.1947622640071E-23, 1.8228094581404E-24, -9.3537087292458E-26 into n1
put 0.461526 into R --kJ/(kg K)
put p / 16.53 into myPi
put 1386 / T into tau
put 0 into gamma
put 0 into gamma_der_tau
repeat with i = 1 to 34
put gamma_der_tau + (n1 * (7.1 - myPi) ^ I1 * J1 * (tau - 1.222) ^ (J1 - 1)) into gamma_der_tau
put gamma + n1 * (7.1 - myPi) ^ I1 * (tau - 1.222) ^ J1 into gamma
end repeat
put R * tau * gamma_der_tau - R * gamma into s1_pT
return s1_pT
end s1_pT
The problem I'm seeing is that the variables gamma and gamma-der_tau never change from the initialized zero value.
Can anyone tell me why? Is there a problem with my use of the 'repeat' control structure, or is the problem with the way I've initialized my arrays? Is the first array index 0 or 1? Something else????