fork download
  1. import numpy as np
  2. from scipy.integrate import odeint
  3.  
  4. # Define the function representing the system of differential equations
  5. def system(y, t):
  6. iL1, iL2 = y
  7. diL1dt = 2 - 4*y[1] - 4*y[0]
  8. diL2dt = 4/9 + 8/9*y[1]
  9. return [diL1dt, diL2dt]
  10.  
  11. # Initial conditions
  12. y0 = [0, 0] # iL1(0) = 0, iL2(0) = 0
  13.  
  14. # Time points to solve the equations at
  15. t = np.linspace(0, 10, 100) # from 0 to 10 seconds
  16.  
  17. # Solve the system of differential equations
  18. solution = odeint(system, y0, t)
  19.  
  20. # Extracting the solutions for iL1 and iL2
  21. iL1_solution = solution[:, 0]
  22. iL2_solution = solution[:, 1]
  23.  
  24. print("iL1_solution:", iL1_solution)
  25. print("iL2_solution:", iL2_solution)
  26.  
  27.  
  28. # Extracting the solutions for iL1 and iL2
  29. iL1_solution = solution[:, 0]
  30. iL2_solution = solution[:, 1]
  31.  
Success #stdin #stdout 0.27s 54524KB
stdin
Standard input is empty
stdout
iL1_solution: [ 0.00000000e+00  1.57977633e-01  2.47062427e-01  2.88614065e-01
  2.96748049e-01  2.80729971e-01  2.46572670e-01  1.98101143e-01
  1.37661961e-01  6.65952124e-02 -1.44522045e-02 -1.05319502e-01
 -2.06195864e-01 -3.17531985e-01 -4.39983621e-01 -5.74376767e-01
 -7.21687546e-01 -8.83032193e-01 -1.05966413e+00 -1.25297612e+00
 -1.46450616e+00 -1.69594634e+00 -1.94915416e+00 -2.22616586e+00
 -2.52921186e+00 -2.86073400e+00 -3.22340481e+00 -3.62014871e+00
 -4.05416545e+00 -4.52895564e+00 -5.04834911e+00 -5.61653559e+00
 -6.23809854e+00 -6.91805203e+00 -7.66188123e+00 -8.47558661e+00
 -9.36573236e+00 -1.03394993e+01 -1.14047430e+01 -1.25700566e+01
 -1.38448411e+01 -1.52393800e+01 -1.67649233e+01 -1.84337777e+01
 -2.02594058e+01 -2.22565353e+01 -2.44412771e+01 -2.68312557e+01
 -2.94457512e+01 -3.23058550e+01 -3.54346398e+01 -3.88573457e+01
 -4.26015839e+01 -4.66975596e+01 -5.11783152e+01 -5.60799975e+01
 -6.14421486e+01 -6.73080255e+01 -7.37249485e+01 -8.07446837e+01
 -8.84238600e+01 -9.68244253e+01 -1.06014148e+02 -1.16067162e+02
 -1.27064566e+02 -1.39095078e+02 -1.52255747e+02 -1.66652743e+02
 -1.82402206e+02 -1.99631190e+02 -2.18478681e+02 -2.39096724e+02
 -2.61651647e+02 -2.86325401e+02 -3.13317032e+02 -3.42844284e+02
 -3.75145355e+02 -4.10480820e+02 -4.49135733e+02 -4.91421927e+02
 -5.37680528e+02 -5.88284707e+02 -6.43642693e+02 -7.04201062e+02
 -7.70448344e+02 -8.42918960e+02 -9.22197539e+02 -1.00892363e+03
 -1.10379684e+03 -1.20758255e+03 -1.32111798e+03 -1.44531905e+03
 -1.58118768e+03 -1.72981995e+03 -1.89241488e+03 -2.07028413e+03
 -2.26486261e+03 -2.47771998e+03 -2.71057338e+03 -2.96530123e+03]
iL2_solution: [0.00000000e+00 4.69704915e-02 9.83534371e-02 1.54563347e-01
 2.16053671e-01 2.83320457e-01 3.56906351e-01 4.37404976e-01
 5.25465721e-01 6.21798978e-01 7.27181877e-01 8.42464549e-01
 9.68576988e-01 1.10653655e+00 1.25745618e+00 1.42255334e+00
 1.60315989e+00 1.80073280e+00 2.01686590e+00 2.25330275e+00
 2.51195072e+00 2.79489634e+00 3.10442214e+00 3.44302511e+00
 3.81343676e+00 4.21864525e+00 4.66191943e+00 5.14683521e+00
 5.67730450e+00 6.25760657e+00 6.89242276e+00 7.58687421e+00
 8.34656313e+00 9.17761798e+00 1.00867429e+01 1.10812720e+01
 1.21692281e+01 1.33593878e+01 1.46613523e+01 1.60856247e+01
 1.76436946e+01 1.93481311e+01 2.12126840e+01 2.32523949e+01
 2.54837182e+01 2.79246543e+01 3.05948943e+01 3.35159792e+01
 3.67114737e+01 4.02071561e+01 4.40312264e+01 4.82145336e+01
 5.27908248e+01 5.77970173e+01 6.32734964e+01 6.92644414e+01
 7.58181816e+01 8.29875867e+01 9.08304927e+01 9.94101690e+01
 1.08795829e+02 1.19063186e+02 1.30295070e+02 1.42582087e+02
 1.56023359e+02 1.70727317e+02 1.86812580e+02 2.04408908e+02
 2.23658252e+02 2.44715898e+02 2.67751721e+02 2.92951552e+02
 3.20518680e+02 3.50675491e+02 3.83665262e+02 4.19754125e+02
 4.59233211e+02 5.02421002e+02 5.49665896e+02 6.01349022e+02
 6.57887312e+02 7.19736864e+02 7.87396625e+02 8.61412409e+02
 9.42381310e+02 1.03095651e+03 1.12785255e+03 1.23385110e+03
 1.34980725e+03 1.47665645e+03 1.61542198e+03 1.76722328e+03
 1.93328494e+03 2.11494661e+03 2.31367374e+03 2.53106950e+03
 2.76888764e+03 3.02904663e+03 3.31364523e+03 3.62497929e+03]