def test_calc(): M = DotMap() M.PC = 40 M.PEEP0 = 5 M.RR = 18 M.IT = 1 M.Pbar = 760 P1 = DotMap() P1.H = 140 P1.W = 55 P1.Cr = 15 P1.PF = 100 P1.HCO3 = 24 P1.FGFO = 8 P1.FGFA = 2 P1.PEEP = 5 P2 = DotMap() P2.H = 180 P2.W = 70 P2.Cr = 50 P2.PF = 300 P2.HCO3 = 24 P2.FGFO = 1 P2.FGFA = 8 P2.PEEP = 5 solver(M, P1, P2)
def objfun(x): tempM = DotMap(M) tempP1 = DotMap(P1) tempP2 = DotMap(P2) tempM.RR = x[0] tempP1.FGFA = x[1] tempP2.FGFA = x[2] tempP1.FGFO = x[3] tempP2.FGFO = x[4] tempP1.PEEP = x[5] tempP2.PEEP = x[6] tempM, tempP1, tempP2 = calc(tempM, tempP1, tempP2) E = objective(tempP1, tempP2) #print(list(x), E) return E