Franny Dean commited on
Commit
d4dd864
1 Parent(s): e65991c

no globals

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +8 -14
  2. app.py +8 -14
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -388,10 +388,6 @@ def Plv(volume, Emax, Emin, t, Tc, Vd):
388
  def Elastance(Emax,Emin, t, Tc):
389
  t = t-int(t/Tc)*Tc #can remove this if only want 1st ED (and the 1st ES before)
390
  tn = t/(0.2+0.15*Tc)
391
- print(tn)
392
- print(Emax)
393
- print(Emin)
394
- print(Tc)
395
  return (Emax-Emin)*1.55*(tn/0.7)**1.9/((tn/0.7)**1.9+1.0)*1.0/((tn/1.17)**21.9+1.0) + Emin
396
 
397
  def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
@@ -550,11 +546,10 @@ def lvad_ode(y, t, Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emax, Emin, Tc, Vd, ratew):
550
  return dydt
551
 
552
  #returns pv loop and ef when there is no lvad:
553
- def f_nolvad(Tc, start_v, Emax, showpvloop):
554
 
555
  N = 20
556
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
557
-
558
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
559
  start_pao = 75.
560
  start_pa = start_pao
@@ -585,10 +580,10 @@ def f_nolvad(Tc, start_v, Emax, showpvloop):
585
  return ef, pao_ed, pao_es, ((ved - ves) * 60/Tc ) / 1000, sol[19*60000, 0], sol[19*60000, 1], sol[19*60000, 2], sol[19*60000, 3], sol[19*60000, 4], result_Vlv[18*60000:20*60000], result_Plv[18*60000:20*60000]
586
 
587
  #returns the w at which suction occurs: (i.e. for which the slope of the envelopes of x6 becomes negative)
588
- def get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #slope is slope0 for w
589
 
590
  N = 70
591
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
592
 
593
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
594
  start_pao = 75.
@@ -657,10 +652,9 @@ def get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #s
657
 
658
  return suction_w
659
 
660
- def f_lvad(Tc, start_v, Emax, c, slope, w0, x60, y00, y01, y02, y03, y04): #slope is slope0 for w
661
 
662
  N = 70
663
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
664
 
665
  y0 = [y00, y01, y02, y03, y04, x60, w0]
666
 
@@ -793,7 +787,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
793
  Ls=0.0005
794
 
795
  #get values for periodic loops:
796
- ef_nolvad, pao_ed, pao_es, co_nolvad, y00, y01, y02, y03, y04, Vlv0, Plv0 = f_nolvad(Tc, start_v, Emax, 0.0)
797
  #pao_eds = [pao_ed]
798
  #pao_ess = [pao_es]
799
 
@@ -801,7 +795,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
801
  w0 = 5000.
802
  ratew = 400.
803
  x60 = 0.
804
- suctionw = get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew)
805
 
806
  #gamma = 1.8
807
  c = 0.065 #(in simaan2008dynamical: 0.67, but too fast -> 0.061 gives better shape)
@@ -809,7 +803,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
809
  w0 = suctionw / gamma #if doesn't work (x6 negative), change gamma down to 1.4 or up to 2.1
810
 
811
  #compute new pv loops and ef with lvad added:
812
- new_ef, pao_ed, pao_es, CO, MAP, Vlvs, Plvs = f_lvad(Tc, start_v, Emax, c, slope0, w0, x60, y00, y01, y02, y03, y04)
813
 
814
  print("\nParameters: Tc, start_v, Emax:", Tc, start_v, Emax)
815
  print("Suction speed:", suctionw)
 
388
  def Elastance(Emax,Emin, t, Tc):
389
  t = t-int(t/Tc)*Tc #can remove this if only want 1st ED (and the 1st ES before)
390
  tn = t/(0.2+0.15*Tc)
 
 
 
 
391
  return (Emax-Emin)*1.55*(tn/0.7)**1.9/((tn/0.7)**1.9+1.0)*1.0/((tn/1.17)**21.9+1.0) + Emin
392
 
393
  def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
 
546
  return dydt
547
 
548
  #returns pv loop and ef when there is no lvad:
549
+ def f_nolvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, showpvloop):
550
 
551
  N = 20
552
+
 
553
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
554
  start_pao = 75.
555
  start_pa = start_pao
 
580
  return ef, pao_ed, pao_es, ((ved - ves) * 60/Tc ) / 1000, sol[19*60000, 0], sol[19*60000, 1], sol[19*60000, 2], sol[19*60000, 3], sol[19*60000, 4], result_Vlv[18*60000:20*60000], result_Plv[18*60000:20*60000]
581
 
582
  #returns the w at which suction occurs: (i.e. for which the slope of the envelopes of x6 becomes negative)
583
+ def get_suctionw(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #slope is slope0 for w
584
 
585
  N = 70
586
+
587
 
588
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
589
  start_pao = 75.
 
652
 
653
  return suction_w
654
 
655
+ def f_lvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, c, slope, w0, x60, y00, y01, y02, y03, y04): #slope is slope0 for w
656
 
657
  N = 70
 
658
 
659
  y0 = [y00, y01, y02, y03, y04, x60, w0]
660
 
 
787
  Ls=0.0005
788
 
789
  #get values for periodic loops:
790
+ ef_nolvad, pao_ed, pao_es, co_nolvad, y00, y01, y02, y03, y04, Vlv0, Plv0 = f_nolvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd,Tc, start_v, Emax, 0.0)
791
  #pao_eds = [pao_ed]
792
  #pao_ess = [pao_es]
793
 
 
795
  w0 = 5000.
796
  ratew = 400.
797
  x60 = 0.
798
+ suctionw = get_suctionw(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew)
799
 
800
  #gamma = 1.8
801
  c = 0.065 #(in simaan2008dynamical: 0.67, but too fast -> 0.061 gives better shape)
 
803
  w0 = suctionw / gamma #if doesn't work (x6 negative), change gamma down to 1.4 or up to 2.1
804
 
805
  #compute new pv loops and ef with lvad added:
806
+ new_ef, pao_ed, pao_es, CO, MAP, Vlvs, Plvs = f_lvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, c, slope0, w0, x60, y00, y01, y02, y03, y04)
807
 
808
  print("\nParameters: Tc, start_v, Emax:", Tc, start_v, Emax)
809
  print("Suction speed:", suctionw)
app.py CHANGED
@@ -388,10 +388,6 @@ def Plv(volume, Emax, Emin, t, Tc, Vd):
388
  def Elastance(Emax,Emin, t, Tc):
389
  t = t-int(t/Tc)*Tc #can remove this if only want 1st ED (and the 1st ES before)
390
  tn = t/(0.2+0.15*Tc)
391
- print(tn)
392
- print(Emax)
393
- print(Emin)
394
- print(Tc)
395
  return (Emax-Emin)*1.55*(tn/0.7)**1.9/((tn/0.7)**1.9+1.0)*1.0/((tn/1.17)**21.9+1.0) + Emin
396
 
397
  def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
@@ -550,11 +546,10 @@ def lvad_ode(y, t, Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emax, Emin, Tc, Vd, ratew):
550
  return dydt
551
 
552
  #returns pv loop and ef when there is no lvad:
553
- def f_nolvad(Tc, start_v, Emax, showpvloop):
554
 
555
  N = 20
556
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
557
-
558
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
559
  start_pao = 75.
560
  start_pa = start_pao
@@ -585,10 +580,10 @@ def f_nolvad(Tc, start_v, Emax, showpvloop):
585
  return ef, pao_ed, pao_es, ((ved - ves) * 60/Tc ) / 1000, sol[19*60000, 0], sol[19*60000, 1], sol[19*60000, 2], sol[19*60000, 3], sol[19*60000, 4], result_Vlv[18*60000:20*60000], result_Plv[18*60000:20*60000]
586
 
587
  #returns the w at which suction occurs: (i.e. for which the slope of the envelopes of x6 becomes negative)
588
- def get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #slope is slope0 for w
589
 
590
  N = 70
591
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
592
 
593
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
594
  start_pao = 75.
@@ -657,10 +652,9 @@ def get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #s
657
 
658
  return suction_w
659
 
660
- def f_lvad(Tc, start_v, Emax, c, slope, w0, x60, y00, y01, y02, y03, y04): #slope is slope0 for w
661
 
662
  N = 70
663
- global Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd
664
 
665
  y0 = [y00, y01, y02, y03, y04, x60, w0]
666
 
@@ -793,7 +787,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
793
  Ls=0.0005
794
 
795
  #get values for periodic loops:
796
- ef_nolvad, pao_ed, pao_es, co_nolvad, y00, y01, y02, y03, y04, Vlv0, Plv0 = f_nolvad(Tc, start_v, Emax, 0.0)
797
  #pao_eds = [pao_ed]
798
  #pao_ess = [pao_es]
799
 
@@ -801,7 +795,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
801
  w0 = 5000.
802
  ratew = 400.
803
  x60 = 0.
804
- suctionw = get_suctionw(Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew)
805
 
806
  #gamma = 1.8
807
  c = 0.065 #(in simaan2008dynamical: 0.67, but too fast -> 0.061 gives better shape)
@@ -809,7 +803,7 @@ def lvad_plots(Rm, Ra, Emax, Emin, Vd, Tc, start_v, gamma):
809
  w0 = suctionw / gamma #if doesn't work (x6 negative), change gamma down to 1.4 or up to 2.1
810
 
811
  #compute new pv loops and ef with lvad added:
812
- new_ef, pao_ed, pao_es, CO, MAP, Vlvs, Plvs = f_lvad(Tc, start_v, Emax, c, slope0, w0, x60, y00, y01, y02, y03, y04)
813
 
814
  print("\nParameters: Tc, start_v, Emax:", Tc, start_v, Emax)
815
  print("Suction speed:", suctionw)
 
388
  def Elastance(Emax,Emin, t, Tc):
389
  t = t-int(t/Tc)*Tc #can remove this if only want 1st ED (and the 1st ES before)
390
  tn = t/(0.2+0.15*Tc)
 
 
 
 
391
  return (Emax-Emin)*1.55*(tn/0.7)**1.9/((tn/0.7)**1.9+1.0)*1.0/((tn/1.17)**21.9+1.0) + Emin
392
 
393
  def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
 
546
  return dydt
547
 
548
  #returns pv loop and ef when there is no lvad:
549
+ def f_nolvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, showpvloop):
550
 
551
  N = 20
552
+
 
553
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
554
  start_pao = 75.
555
  start_pa = start_pao
 
580
  return ef, pao_ed, pao_es, ((ved - ves) * 60/Tc ) / 1000, sol[19*60000, 0], sol[19*60000, 1], sol[19*60000, 2], sol[19*60000, 3], sol[19*60000, 4], result_Vlv[18*60000:20*60000], result_Plv[18*60000:20*60000]
581
 
582
  #returns the w at which suction occurs: (i.e. for which the slope of the envelopes of x6 becomes negative)
583
+ def get_suctionw(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew): #slope is slope0 for w
584
 
585
  N = 70
586
+
587
 
588
  start_pla = float(start_v*Elastance(Emax, Emin, 0.0, Tc))
589
  start_pao = 75.
 
652
 
653
  return suction_w
654
 
655
+ def f_lvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, c, slope, w0, x60, y00, y01, y02, y03, y04): #slope is slope0 for w
656
 
657
  N = 70
 
658
 
659
  y0 = [y00, y01, y02, y03, y04, x60, w0]
660
 
 
787
  Ls=0.0005
788
 
789
  #get values for periodic loops:
790
+ ef_nolvad, pao_ed, pao_es, co_nolvad, y00, y01, y02, y03, y04, Vlv0, Plv0 = f_nolvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd,Tc, start_v, Emax, 0.0)
791
  #pao_eds = [pao_ed]
792
  #pao_ess = [pao_es]
793
 
 
795
  w0 = 5000.
796
  ratew = 400.
797
  x60 = 0.
798
+ suctionw = get_suctionw(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, y00, y01, y02, y03, y04, w0, x60, ratew)
799
 
800
  #gamma = 1.8
801
  c = 0.065 #(in simaan2008dynamical: 0.67, but too fast -> 0.061 gives better shape)
 
803
  w0 = suctionw / gamma #if doesn't work (x6 negative), change gamma down to 1.4 or up to 2.1
804
 
805
  #compute new pv loops and ef with lvad added:
806
+ new_ef, pao_ed, pao_es, CO, MAP, Vlvs, Plvs = f_lvad(Rs, Rm, Ra, Rc, Ca, Cs, Cr, Ls, Emin, Vd, Tc, start_v, Emax, c, slope0, w0, x60, y00, y01, y02, y03, y04)
807
 
808
  print("\nParameters: Tc, start_v, Emax:", Tc, start_v, Emax)
809
  print("Suction speed:", suctionw)