Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lyopronto/calc_knownRp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def dry(vial,product,ht,Pchamber,Tshelf,dt):
################## Initialization ################

# Initial fill height
Lpr0 = functions.Lpr0_FUN(vial['Vfill'],vial['Ap'],product['cSolid']) # cm
Lpr0 = functions.Lpr0_FUN(vial['Vfill'],vial['Ap'],product['cSolid']) # [cm]

# Time-dependent functions for Pchamber and Tshelf, take time in hours
Pch_t = functions.RampInterpolator(Pchamber)
Expand All @@ -58,7 +58,7 @@ def dry(vial,product,ht,Pchamber,Tshelf,dt):
# Get maximum simulation time based on shelf and chamber setpoints
# This may not really be necessary, but is part of legacy behavior
# Could remove in a future release
max_t = max(Pch_t.max_time(), Tsh_t.max_time()) # hr, add buffer
max_t = max(Pch_t.max_time(), Tsh_t.max_time()) # [hr], add buffer

if Pch_t.max_setpt() > functions.Vapor_pressure(Tsh_t.max_setpt()):
warn("Chamber pressure setpoint exceeds vapor pressure at shelf temperature " +\
Expand All @@ -75,21 +75,21 @@ def dry(vial,product,ht,Pchamber,Tshelf,dt):
# taking them as arguments.
def calc_dLdt(t, u):
# Time in hours
Lck = u[0] # cm
Lck = u[0] # [cm]
Tsh = Tsh_t(t)
Pch = Pch_t(t)
Kv = functions.Kv_FUN(ht['KC'],ht['KP'],ht['KD'],Pch) # Vial heat transfer coefficient in cal/s/K/cm^2
Rp = functions.Rp_FUN(Lck,product['R0'],product['A1'],product['A2']) # Product resistance in cm^2-hr-Torr/g
Tsub = fsolve(functions.T_sub_solver_FUN, T0, args = (Pch,vial['Av'],vial['Ap'],Kv,Lpr0,Lck,Rp,Tsh))[0] # Sublimation front temperature array in degC
dmdt = functions.sub_rate(vial['Ap'],Rp,Tsub,Pch) # Total sublimation rate array in kg/hr
Kv = functions.Kv_FUN(ht['KC'],ht['KP'],ht['KD'],Pch) # Vial heat transfer coefficient [cal/s/K/cm^2]
Rp = functions.Rp_FUN(Lck,product['R0'],product['A1'],product['A2']) # Product resistance [cm^2-hr-Torr/g]
Tsub = fsolve(functions.T_sub_solver_FUN, T0, args = (Pch,vial['Av'],vial['Ap'],Kv,Lpr0,Lck,Rp,Tsh))[0] # Sublimation front temperature [degC]
dmdt = functions.sub_rate(vial['Ap'],Rp,Tsub,Pch) # Total sublimation rate [kg/hr]
if dmdt<0:
# print("Shelf temperature is too low for sublimation.")
dmdt = 0.0
dLdt = 0
return [dLdt]
# Tbot = functions.T_bot_FUN(Tsub,Lpr0,Lck,Pch,Rp) # Vial bottom temperature array in degC

dLdt = (dmdt*constant.kg_To_g)/(1-product['cSolid']*constant.rho_solution/constant.rho_solute)/(vial['Ap']*constant.rho_ice)*(1-product['cSolid']*(constant.rho_solution-constant.rho_ice)/constant.rho_solute) # cm/hr
dLdt = (dmdt*constant.kg_To_g)/(1-product['cSolid']*constant.rho_solution/constant.rho_solute)/(vial['Ap']*constant.rho_ice)*(1-product['cSolid']*(constant.rho_solution-constant.rho_ice)/constant.rho_solute) # [cm/hr]
return [dLdt]

### ------ Condition for ending simulation: completed drying
Expand Down
20 changes: 10 additions & 10 deletions lyopronto/calc_unknownRp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ def dry(vial,product,ht,Pchamber,Tshelf,time,Tbot_exp):
################## Initialization ################

# Initial fill height
Lpr0 = functions.Lpr0_FUN(vial['Vfill'],vial['Ap'],product['cSolid']) # cm
Lpr0 = functions.Lpr0_FUN(vial['Vfill'],vial['Ap'],product['cSolid']) # [cm]

# Initialization of cake length
Lck = 0.0 # Cake length in cm
Lck = 0.0 # Cake length [cm]
percent_dried = Lck/Lpr0*100.0 # Percent dried

# Initial shelf temperature
Tsh = Tshelf['init'] # degC
Tsh = Tshelf['init'] # [degC]
Tshelf = Tshelf.copy() # Don't edit the original argument!!
Tshelf['setpt'] = np.insert(Tshelf['setpt'],0,Tshelf['init']) # Include initial shelf temperature in set point array
# Shelf temperature control time
Expand All @@ -43,7 +43,7 @@ def dry(vial,product,ht,Pchamber,Tshelf,time,Tbot_exp):
Tshelf['t_setpt'] = np.append(Tshelf['t_setpt'],Tshelf['t_setpt'][-1]+dt_i/constant.hr_To_min)

# Initial chamber pressure
Pch = Pchamber['setpt'][0] # Torr
Pch = Pchamber['setpt'][0] # [Torr]
Pchamber = Pchamber.copy() # Don't edit the original argument!!
Pchamber['setpt'] = np.insert(Pchamber['setpt'],0,Pchamber['setpt'][0]) # Include initial chamber pressure in set point array
# Chamber pressure control time
Expand All @@ -60,20 +60,20 @@ def dry(vial,product,ht,Pchamber,Tshelf,time,Tbot_exp):

for iStep,t in enumerate(time): # Loop through for the time specified in the input file

Kv = functions.Kv_FUN(ht['KC'],ht['KP'],ht['KD'],Pch) # Vial heat transfer coefficient in cal/s/K/cm^2
Kv = functions.Kv_FUN(ht['KC'],ht['KP'],ht['KD'],Pch) # Vial heat transfer coefficient [cal/s/K/cm^2]

Tsub = sp.fsolve(functions.T_sub_Rp_finder, Tbot_exp[iStep], args = (vial['Av'],vial['Ap'],Kv,Lpr0,Lck,Tbot_exp[iStep],Tsh))[0] # Sublimation front temperature array in degC
Tsub = sp.fsolve(functions.T_sub_Rp_finder, Tbot_exp[iStep], args = (vial['Av'],vial['Ap'],Kv,Lpr0,Lck,Tbot_exp[iStep],Tsh))[0] # Sublimation front temperature [degC]
# Q = Kv*vial['Av']*(Tsh - Tbot_exp[iStep])
# Tsub = Tbot_exp[iStep] - Q/vial['Ap']/constant.k_ice*(Lpr0-Lck)
Rp = functions.Rp_finder(Tsub,Lpr0,Lck,Pch,Tbot_exp[iStep]) # Product resistance in cm^2-Torr-hr/g
dmdt = functions.sub_rate(vial['Ap'],Rp,Tsub,Pch) # Total sublimation rate array in kg/hr
Rp = functions.Rp_finder(Tsub,Lpr0,Lck,Pch,Tbot_exp[iStep]) # Product resistance [cm^2-Torr-hr/g]
dmdt = functions.sub_rate(vial['Ap'],Rp,Tsub,Pch) # Total sublimation rate [kg/hr]
if dmdt<0:
warn(f"No sublimation. t={t:1.2f}, Tsh={Tsh:2.1f}, Tsub={Tsub:3.1f}, dmdt={dmdt:1.2e}, Rp={Rp:1.2f}, Lck={Lck:1.2f}")
dmdt = 0.0
Rp = 0.0

# Sublimated ice length
dL = (dmdt*constant.kg_To_g)*dt[iStep]/(1-product['cSolid']*constant.rho_solution/constant.rho_solute)/(vial['Ap']*constant.rho_ice)*(1-product['cSolid']*(constant.rho_solution-constant.rho_ice)/constant.rho_solute) # cm
dL = (dmdt*constant.kg_To_g)*dt[iStep]/(1-product['cSolid']*constant.rho_solution/constant.rho_solute)/(vial['Ap']*constant.rho_ice)*(1-product['cSolid']*(constant.rho_solution-constant.rho_ice)/constant.rho_solute) # [cm]

# Update record as functions of the cycle time
if (iStep==0):
Expand All @@ -84,7 +84,7 @@ def dry(vial,product,ht,Pchamber,Tshelf,time,Tbot_exp):
product_res = np.append(product_res, [[t, float(Lck), float(Rp)]],axis=0)

# Advance counters
Lck = Lck + dL # Cake length in cm
Lck = Lck + dL # Cake length [cm]

percent_dried = Lck/Lpr0*100 # Percent dried

Expand Down
16 changes: 8 additions & 8 deletions lyopronto/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
Torr_to_mTorr = 1000.0
cal_To_J = 4.184

rho_ice = 0.918 # g/mL
rho_solute = 1.5 # g/mL
rho_solution = 1.0 # g/mL
rho_ice = 0.918 # [g/mL]
rho_solute = 1.5 # [g/mL]
rho_solution = 1.0 # [g/mL]

dHs = 678.0 # Heat of sublimation in cal/g
k_ice = 0.0059 # Thermal conductivity of ice in cal/cm/s/K
dHf = 79.7 # Heat of fusion in cal/g
dHs = 678.0 # Heat of sublimation [cal/g]
k_ice = 0.0059 # Thermal conductivity of ice [cal/cm/s/K]
dHf = 79.7 # Heat of fusion [cal/g]

Cp_ice = 2030.0 # Constant pressure specific heat of ice in J/kg/K
Cp_solution = 4000.0 # Constant pressure specific heat of water in J/kg/K
Cp_ice = 2030.0 # Constant pressure specific heat of ice [J/kg/K]
Cp_solution = 4000.0 # Constant pressure specific heat of water [J/kg/K]

##################################################
Loading
Loading