Skip to content Skip to sidebar Skip to footer

Does The Order Of The Equations In A Coupled Oident Solver Matter?

My code runs, however, if i change the order of the equations defined in my formula my graphs changes as well. Can somebody tell me why this is? Now i do not know what the right gr

Solution 1:

In the second code snippet you are referring to e.g. u_1 before you assign it. The same goes for u_2 ... u_4. So whatever the values of those are before the assignments get used in the calculations for du1dt...duddt

Solution 2:

In the code block

     u_1 = (L_L*u_s + w_L*u_2)/w_L
     u_2 = (w_d*u_d)/w_L
     u_3 = (w_L*u_2)/w_r
     u_4 = (L_r*u_s + w_r*u_3)/w_r
     u_d = (w_r*u_3)/w_d

you change all the u values. Of course it makes a difference in the function if you compute further values with the modified or unmodified u values.

The easiest thing to do is not to re-use these variable names. Change u to v on the left side and then check whether in uses further down you really wanted to use the modified v value or the u value. Your original code with that change would be

     v_1 = (L_L*u_s + w_L*u_2)/w_L
     v_2 = (w_d*u_d)/w_L
     v_3 = (w_L*v_2)/w_r
     v_4 = (L_r*u_s + w_r*v_3)/w_r
     v_d = (w_r*v_3)/w_d

     du1dt =  - g*((p_2-p_1)/L_L + deltap_L/L_L) - b_L*v_1 
     du2dt =  - g*((p_2-p_1)/L_L - deltap_L/L_L) - b_L*v_2
     du3dt =  - g*((p_4-p_3)/L_r - deltap_R/L_r) - b_R*v_3
     du4dt =  - g*((p_4-p_3)/L_r + deltap_R/L_r) - b_R*v_4
     duddt =  - g*((p_3-p_2)/L_d) - b_D *v_d




     dp1dt =  - v_1
     dp2dt =  - v_1
     dp3dt = + v_4
     dp4dt = + v_4
     ddeltap_Ldt =  - v_1
     ddeltap_Rdt =  v_4 

Now any re-arrangement of the indicated type will cause an error that some variable used on some right side was not previously defined.

Post a Comment for "Does The Order Of The Equations In A Coupled Oident Solver Matter?"