Question: Using dsolve in a loop and fixing "invalid subscript error"

Hello,

I`m having trouble using dsolve in a loop in order to evaluate a differential equation for different constants/initial values. I`ve imported the data for the constants from excel using the import function and have defined them, and then created the differential equation which returned a DE with array parts. I created a sequence called sys_ode ad sys_init_val so that I could easily call the DE`s individually. I now wish to solve the DE at each of these points using dsolve in a loop by calling each one individually into dsolve, but I keep getting the error "Error, (in dsolve) invalid subscript selector". Here is my code:

> restart; -1; with(ExcelTools); -1; with(DEtools); -1; with(linalg); -1; with(ArrayTools); -1;
Variable Metrics Tank 1
> Charge_rate_V3 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AB4:AB30"); -1;
> Charge_rate_V4 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AC4:AC30"); -1;
> C_V3 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AD4:AD30"); -1;
> C_V4 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AE4:AE30"); -1;
> level_tank_1 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AH4:AH30"); -1;
> Sit_time_tank_1 := 0; -1;
Variable Metrics Tank 2
> level_tank_2 := ExcelTools:-Import("C:\\Users\\Drew Steeves\\Desktop\\OperatorView SP Values.xlsx", "OperatorView SP Values", "AI4:AI30"); -1;
> Sit_time_tank_2 := 0; -1;
Non-Variable Metrics Tank 1
> C_model_tank_1 := (C_V3+C_V4)*(1/2)-.272727*t; -1;
> C_lost_tank_1 := diff(C_model_tank_1, t); -1;
> m_out_tank_1 := Charge_rate_V3+Charge_rate_V4; -1;
> diameter_tank_1 := 20; -1;
> density_asphalt_tank_1 := 1.0426*0.28316e-1; -1;
> M_tank_1 := Pi*((1/2)*diameter_tank_1)^2*level_tank_1*density_asphalt_tank_1; -1;
> Residence_time_tank_1 := M_tank_1/m_out_tank_1; -1;
> Total_time_tank_1 := Sit_time_tank_1+Residence_time_tank_1; -1;
Non-Variable Metrics Tank 2
> C_model_tank_2 := eval(C_tank_1, t = Total_time_tank_1)-.272727*x; -1;
> C_lost_tank_2 := diff(C_model_tank_2, x); -1;
> m_out_tank_2 := Charge_rate_V3+Charge_rate_V4; -1;
> m_in_tank_2 := m_out_tank_1; -1;
> density_asphalt_tank_2 := 1.0426*0.28316e-1; -1;
> diameter_tank_2 := 20; -1;
> M_tank_2 := Pi*((1/2)*diameter_tank_2)^2*level_tank_2*density_asphalt_tank_2; -1;
> Residence_time_tank_2 := M_tank_2/m_out_tank_2; -1;

> Total_time_tank_2 := Residence_time_tank_2+Sit_time_tank_2; -1;
Equation Tank 1
> DE_C_tank_1 := diff(C_1(t), t)+m_out_tank_1*C_1(t)/M_tank_1-C_lost_tank_1 = Charge_rate_V3*C_V3/M_tank_1+Charge_rate_V4*C_V4/M_tank_1; 1;
/ d \
|--- C_1(t)| + Array(%id = 18446744074374639974) = Array(%id = 184467440743746\
\ dt /

36478)
> sys_ode := seq(DE_C_tank_1(i), i = 1 .. 27); -1;
> sys_init_val := seq((C_V3(i)+C_V4(i))*(1/2), i = 1 .. 27); -1;
for i to 27 do soln_tank_1[i] := rhs(dsolve({sys_ode[i], C_1(0) =
sys_init_val[i]}, C_1(t))) end do
Error, (in dsolve) invalid subscript selector

 

Any help would be greatly appreciated! Thanks! -Drew

Please Wait...