Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for DERIVATIVE prevent change. #1404

Open
1uc opened this issue Aug 19, 2024 · 0 comments
Open

Unit tests for DERIVATIVE prevent change. #1404

1uc opened this issue Aug 19, 2024 · 0 comments

Comments

@1uc
Copy link
Collaborator

1uc commented Aug 19, 2024

Even simple changes like:

  • making J row-major
  • (X - X_old)/dt = dX -> X = X_old + dt*dX

are practically almost impossible because they require changing the hard coded reference across 1000s of lines of code. For example,

GIVEN("12 state-var LINEAR solve block") {
std::string nmodl_text = R"(
STATE {
C1 C2 C3 C4 C5 I1 I2 I3 I4 I5 I6 O
}
LINEAR seqinitial {
~ I1*bi1 + C2*b01 - C1*( fi1+f01) = 0
~ C1*f01 + I2*bi2 + C3*b02 - C2*(b01+fi2+f02) = 0
~ C2*f02 + I3*bi3 + C4*b03 - C3*(b02+fi3+f03) = 0
~ C3*f03 + I4*bi4 + C5*b04 - C4*(b03+fi4+f04) = 0
~ C4*f04 + I5*bi5 + O*b0O - C5*(b04+fi5+f0O) = 0
~ C5*f0O + I6*bin0 - O*(b0O+fin0) = 0
~ C1*fi1 + I2*b11 - I1*( bi1+f11) = 0
~ I1*f11 + C2*fi2 + I3*b12 - I2*(b11+bi2+f12) = 0
~ I2*f12 + C3*fi3 + I4*bi3 - I3*(b12+bi3+f13) = 0
~ I3*f13 + C4*fi4 + I5*b14 - I4*(b13+bi4+f14) = 0
~ I4*f14 + C5*fi5 + I6*b1n - I5*(b14+bi5+f1n) = 0
~ C1 + C2 + C3 + C4 + C5 + O + I1 + I2 + I3 + I4 + I5 + I6 = 1
})";
std::string expected_text = R"(
LINEAR seqinitial {
EIGEN_LINEAR_SOLVE[12]{
}{
}{
nmodl_eigen_x[0] = C1
nmodl_eigen_x[1] = C2
nmodl_eigen_x[2] = C3
nmodl_eigen_x[3] = C4
nmodl_eigen_x[4] = C5
nmodl_eigen_x[5] = I1
nmodl_eigen_x[6] = I2
nmodl_eigen_x[7] = I3
nmodl_eigen_x[8] = I4
nmodl_eigen_x[9] = I5
nmodl_eigen_x[10] = I6
nmodl_eigen_x[11] = O
nmodl_eigen_f[0] = 0
nmodl_eigen_f[1] = 0
nmodl_eigen_f[2] = 0
nmodl_eigen_f[3] = 0
nmodl_eigen_f[4] = 0
nmodl_eigen_f[5] = 0
nmodl_eigen_f[6] = 0
nmodl_eigen_f[7] = 0
nmodl_eigen_f[8] = 0
nmodl_eigen_f[9] = 0
nmodl_eigen_f[10] = 0
nmodl_eigen_f[11] = -1.0
nmodl_eigen_j[0] = f01+fi1
nmodl_eigen_j[12] = -b01
nmodl_eigen_j[24] = 0
nmodl_eigen_j[36] = 0
nmodl_eigen_j[48] = 0
nmodl_eigen_j[60] = -bi1
nmodl_eigen_j[72] = 0
nmodl_eigen_j[84] = 0
nmodl_eigen_j[96] = 0
nmodl_eigen_j[108] = 0
nmodl_eigen_j[120] = 0
nmodl_eigen_j[132] = 0
nmodl_eigen_j[1] = -f01
nmodl_eigen_j[13] = b01+f02+fi2
nmodl_eigen_j[25] = -b02
nmodl_eigen_j[37] = 0
nmodl_eigen_j[49] = 0
nmodl_eigen_j[61] = 0
nmodl_eigen_j[73] = -bi2
nmodl_eigen_j[85] = 0
nmodl_eigen_j[97] = 0
nmodl_eigen_j[109] = 0
nmodl_eigen_j[121] = 0
nmodl_eigen_j[133] = 0
nmodl_eigen_j[2] = 0
nmodl_eigen_j[14] = -f02
nmodl_eigen_j[26] = b02+f03+fi3
nmodl_eigen_j[38] = -b03
nmodl_eigen_j[50] = 0
nmodl_eigen_j[62] = 0
nmodl_eigen_j[74] = 0
nmodl_eigen_j[86] = -bi3
nmodl_eigen_j[98] = 0
nmodl_eigen_j[110] = 0
nmodl_eigen_j[122] = 0
nmodl_eigen_j[134] = 0
nmodl_eigen_j[3] = 0
nmodl_eigen_j[15] = 0
nmodl_eigen_j[27] = -f03
nmodl_eigen_j[39] = b03+f04+fi4
nmodl_eigen_j[51] = -b04
nmodl_eigen_j[63] = 0
nmodl_eigen_j[75] = 0
nmodl_eigen_j[87] = 0
nmodl_eigen_j[99] = -bi4
nmodl_eigen_j[111] = 0
nmodl_eigen_j[123] = 0
nmodl_eigen_j[135] = 0
nmodl_eigen_j[4] = 0
nmodl_eigen_j[16] = 0
nmodl_eigen_j[28] = 0
nmodl_eigen_j[40] = -f04
nmodl_eigen_j[52] = b04+f0O+fi5
nmodl_eigen_j[64] = 0
nmodl_eigen_j[76] = 0
nmodl_eigen_j[88] = 0
nmodl_eigen_j[100] = 0
nmodl_eigen_j[112] = -bi5
nmodl_eigen_j[124] = 0
nmodl_eigen_j[136] = -b0O
nmodl_eigen_j[5] = 0
nmodl_eigen_j[17] = 0
nmodl_eigen_j[29] = 0
nmodl_eigen_j[41] = 0
nmodl_eigen_j[53] = -f0O
nmodl_eigen_j[65] = 0
nmodl_eigen_j[77] = 0
nmodl_eigen_j[89] = 0
nmodl_eigen_j[101] = 0
nmodl_eigen_j[113] = 0
nmodl_eigen_j[125] = -bin0
nmodl_eigen_j[137] = b0O+fin0
nmodl_eigen_j[6] = -fi1
nmodl_eigen_j[18] = 0
nmodl_eigen_j[30] = 0
nmodl_eigen_j[42] = 0
nmodl_eigen_j[54] = 0
nmodl_eigen_j[66] = bi1+f11
nmodl_eigen_j[78] = -b11
nmodl_eigen_j[90] = 0
nmodl_eigen_j[102] = 0
nmodl_eigen_j[114] = 0
nmodl_eigen_j[126] = 0
nmodl_eigen_j[138] = 0
nmodl_eigen_j[7] = 0
nmodl_eigen_j[19] = -fi2
nmodl_eigen_j[31] = 0
nmodl_eigen_j[43] = 0
nmodl_eigen_j[55] = 0
nmodl_eigen_j[67] = -f11
nmodl_eigen_j[79] = b11+bi2+f12
nmodl_eigen_j[91] = -b12
nmodl_eigen_j[103] = 0
nmodl_eigen_j[115] = 0
nmodl_eigen_j[127] = 0
nmodl_eigen_j[139] = 0
nmodl_eigen_j[8] = 0
nmodl_eigen_j[20] = 0
nmodl_eigen_j[32] = -fi3
nmodl_eigen_j[44] = 0
nmodl_eigen_j[56] = 0
nmodl_eigen_j[68] = 0
nmodl_eigen_j[80] = -f12
nmodl_eigen_j[92] = b12+bi3+f13
nmodl_eigen_j[104] = -bi3
nmodl_eigen_j[116] = 0
nmodl_eigen_j[128] = 0
nmodl_eigen_j[140] = 0
nmodl_eigen_j[9] = 0
nmodl_eigen_j[21] = 0
nmodl_eigen_j[33] = 0
nmodl_eigen_j[45] = -fi4
nmodl_eigen_j[57] = 0
nmodl_eigen_j[69] = 0
nmodl_eigen_j[81] = 0
nmodl_eigen_j[93] = -f13
nmodl_eigen_j[105] = b13+bi4+f14
nmodl_eigen_j[117] = -b14
nmodl_eigen_j[129] = 0
nmodl_eigen_j[141] = 0
nmodl_eigen_j[10] = 0
nmodl_eigen_j[22] = 0
nmodl_eigen_j[34] = 0
nmodl_eigen_j[46] = 0
nmodl_eigen_j[58] = -fi5
nmodl_eigen_j[70] = 0
nmodl_eigen_j[82] = 0
nmodl_eigen_j[94] = 0
nmodl_eigen_j[106] = -f14
nmodl_eigen_j[118] = b14+bi5+f1n
nmodl_eigen_j[130] = -b1n
nmodl_eigen_j[142] = 0
nmodl_eigen_j[11] = -1.0
nmodl_eigen_j[23] = -1.0
nmodl_eigen_j[35] = -1.0
nmodl_eigen_j[47] = -1.0
nmodl_eigen_j[59] = -1.0
nmodl_eigen_j[71] = -1.0
nmodl_eigen_j[83] = -1.0
nmodl_eigen_j[95] = -1.0
nmodl_eigen_j[107] = -1.0
nmodl_eigen_j[119] = -1.0
nmodl_eigen_j[131] = -1.0
nmodl_eigen_j[143] = -1.0
}{
C1 = nmodl_eigen_x[0]
C2 = nmodl_eigen_x[1]
C3 = nmodl_eigen_x[2]
C4 = nmodl_eigen_x[3]
C5 = nmodl_eigen_x[4]
I1 = nmodl_eigen_x[5]
I2 = nmodl_eigen_x[6]
I3 = nmodl_eigen_x[7]
I4 = nmodl_eigen_x[8]
I5 = nmodl_eigen_x[9]
I6 = nmodl_eigen_x[10]
O = nmodl_eigen_x[11]
}{
}
})";

requires changing well over 100 lines of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant