Skip to content

Commit

Permalink
Merge pull request #307 from AdityaSavara/develop
Browse files Browse the repository at this point in the history
made getLogLikelihood_byResponses (which takes variances for uncertainties)
turned off convergence diagnostics during doe
turned off convergence diagnostics during multi-start (except for best run)
Fixed Example 12 and Example 13 to work with newest PEUQSE and dependencies
  • Loading branch information
AdityaSavara authored Aug 7, 2022
2 parents 7fbd1a2 + 21986fa commit f8443ca
Show file tree
Hide file tree
Showing 101 changed files with 1,561 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
Expand All @@ -27,7 +28,8 @@ def cmr(theta,V,k_1,k_minus_1,k_B,T0):
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
23 changes: 12 additions & 11 deletions Examples/Example12NoScaling/runfile_Example12_km_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -69,18 +69,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -92,7 +93,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
Expand All @@ -27,7 +28,8 @@ def cmr(theta,V,k_1,k_minus_1,k_B,T0):
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -69,18 +69,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -92,7 +93,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
Expand All @@ -27,7 +28,8 @@ def cmr(theta,V,k_1,k_minus_1,k_B,T0):
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -71,18 +71,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -94,7 +95,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
Expand All @@ -27,7 +28,8 @@ def cmr(theta,V,k_1,k_minus_1,k_B,T0):
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -69,18 +69,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -92,7 +93,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
Expand All @@ -27,7 +28,8 @@ def cmr(theta,V,k_1,k_minus_1,k_B,T0):
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -69,18 +69,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -92,7 +93,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
k_minus_1 = 1

def cmr(theta,V,k_1,k_minus_1,k_B,T0):

F_A, F_B = theta
F_T = F_A + F_B
C_T0 = P0 / (R * T0)
C_A = C_T0 * F_A / F_T
C_B = C_T0 * F_B / F_T
r_A = k_1*C_A - k_minus_1*C_B
R_B = np.array(k_B)*np.array(C_B)
R_B = k_B*C_B
dFdV = [-r_A, r_A - R_B]
return dFdV

def mem_reactor(sample):
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample, T))
#sample should be a list with 1 value.
sol = odeint(cmr, F0, np.linspace(0,volume,2), args=(k_1, k_minus_1, sample[0], T))
conc_sol_last=sol[-1,:].T
# print('km',sample)
# print('F_A',conc_sol_last[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import processing_function_mem_reactor_km_only as fun

UserInput.responses['responses_observed_uncertainties'] = 0.04
UserInput.responses['responses_observed_uncertainties'] = [0.04]

UserInput.simulated_response_plot_settings['x_label'] = r'$reactor outlet$'
UserInput.simulated_response_plot_settings['y_label'] = r'$ln(C_A)i$'
Expand Down Expand Up @@ -69,18 +69,19 @@
conc_sol_last=sol[-1,0].T
flow_rates_a.append(conc_sol_last)

fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(111, projection='3d')
#fig = plt.figure(figsize = (5,5))
#ax = fig.add_subplot(111, projection='3d')
fig1,ax1 = plt.subplots(figsize=(5,5))
TT, V = np.meshgrid(temperatures, volumes)
flow_rates_a=np.asarray(flow_rates_a)
FRA = flow_rates_a.reshape(TT.shape)
surf = ax.plot_surface(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax.set_xlabel('Temperature')
ax.set_ylabel('Volume')
ax.set_zlabel('Flow Rate')
ax.set_title('Surface Plot of F_A')
fig.colorbar(surf, shrink=0.5, aspect=5)
fig.savefig('synthetic_observables.png',dpi=220)
surf = ax1.pcolor(TT,V,FRA,cmap=matplotlib.cm.coolwarm)
ax1.set_xlabel('Temperature')
ax1.set_ylabel('Volume')
#ax1.set_zlabel('Flow Rate')
ax1.set_title('Surface Plot of F_A')
fig1.colorbar(surf, shrink=0.5, aspect=5)
fig1.savefig('synthetic_observables.png',dpi=220)

fun.k_1 = 1e2
fun.k_minus_1 = 1
Expand All @@ -92,7 +93,7 @@
sol = odeint(fun.cmr, F0, np.linspace(0,v,50), args=(k_1,k_minus_1,k_m,t))
conc_sol_last=sol[-1,0].T
print('conc_sol_last',conc_sol_last)
UserInput.responses['responses_observed'] = conc_sol_last
UserInput.responses['responses_observed'] = [conc_sol_last]
PE_object_list.append(PEUQSE.parameter_estimation(UserInput))
fun.T = t
fun.volume = v
Expand Down
Loading

0 comments on commit f8443ca

Please sign in to comment.