def __init__(self): self.compressor = Compressor() self.turbine = Turbine() self.initial_guess = self.__class__.DEFAULT_PARAMS.copy() self.cpc = 1004 # J/(kg K) self.cpt = 1225 # J/(kg K) self.T01 = 273.15 # K self.P01 = 101e3 # Pa self.R_c = (1 - 1 / self.compressor.gam) * self.cpc # from gam and cp self.R_t = (1 - 1 / self.turbine.gam) * self.cpt self.A8 = pi / 4 * 35e-3**2 # Measured: D8 = 45mm self.FHV = 43e6 #J/kg Fuel lower calorific value self.eta_combustion = 0.5
def __init__(self,V=1000.,cmp_eff=80.,trb_eff=90.,p=200000): # Air Side self.amb = Ambient() self.cmp = Compressor(eff=cmp_eff) self.tank = Tank(V=V,p=p) self.trb = Turbine(eff=trb_eff) self.m_dot_i = 0.0 self.m_dot_o = 0.0 # Heat Side # Create pandas DataFrame to store results self.df = pd.DataFrame(columns=variables)
def suctionside(inputData): turbine, conditions = Turbine.by_conditions(*inputData, lambd=3.5) newconditions = np.array([ conditions[0], np.array([0.22, 0.94]), np.array([0.5, .97]), np.array([0.77, .7]), conditions[6] ]) # plt.plot(newconditions[:,0], newconditions[:,1]) # plt.show() tvals = util.spacing(newconditions, (0, 1), 'uniform') knots = np.array([0, 0, 0, 0, 1 / 3. * sum(tvals[1:4]), 1, 1, 1, 1]) basis = util.basisarray(3, knots) der0 = basis[-1] rang = 5 probmatrix = np.array([ [der0[i](tvals[0]) for i in range(rang)], [der0[i](tvals[1]) for i in range(rang)], [der0[i](tvals[2]) for i in range(rang)], [der0[i](tvals[3]) for i in range(rang)], [der0[i](tvals[4]) for i in range(rang)], ]) xpts = np.linalg.solve(probmatrix, newconditions[:, 0]) ypts = np.linalg.solve(probmatrix, newconditions[:, 1]) return Spline(np.array([xpts, ypts]), knots)
def spawn(self, dna): x, y = dna['x'], dna['y'] obj = Turbine(x, y) if indivCheckConstraints(obj, self.coords, self.config['dia']): return obj else: del obj return 0
def __init__(self): self.config = config() self.idx = 0 self.coords = [] self.pop = [] self.losses = [] self.pool = [] self.thresh = 0.3 corners = [[clearance, clearance], [limit - clearance, clearance], [clearance, limit - clearance], [limit - clearance, limit - clearance]] for i, coord in enumerate(corners): obj = Turbine() for j in range(0, life): obj.dna[j] = coord self.pop.append(obj) for i in range(0, num - 4): obj = Turbine() self.pop.append(obj)
def validate(args): config = TurbineConfig.load(args.Config_file) config.environment.load = args.Environment_file # Set given path as environment.xml path env_file = ET.parse(config.environment.load) robot_xml = env_file.find('Robot') robot_xml.attrib['file'] = args.Robot_file env_file.write(config.environment.load) # Set given path as robot.xml path turbine = Turbine(config) DB = db.DB(join(environ['PYTHON_DATABASE'], area_db[args.Area]), turbine) success = blade_coverage.base_grid_validation_parser( turbine, DB, args.Grid, args.Trajectory_file) if not success: print "could not find the required coating trajectory" sys.exit(1)
from numpy import pi, array, dot import dynamics import matplotlib.pylab as plt import matplotlib.gridspec as gridspec from turbine import Turbine # Turn off gravity dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = True # Create model bladed_file = r'C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj' tb = Turbine(bladed_file, rigid=False) tb.set_base_motion(4, 0.80, 10 * pi / 180) #t,y = tb.simulate(rotor_speed=2, t1=60, dt=0.05, init=True) def p(parts=False): fig = plt.figure() fig.set_size_inches(15, 10, forward=True) gs = gridspec.GridSpec(6, 2) motion = ['surge', 'sway', 'heave', 'roll', 'pitch', 'yaw'][tb.base_motion] fig.suptitle('Blade loads in response to base motion: {}'.format(motion)) assert motion == 'pitch' az = [y[1][:, 0], y[6][:, 0], y[11][:, 0]] pitch = [ y[0][:, tb.base_motion], y[5][:, tb.base_motion], y[10][:,
from turbine import Turbine from turbine_config import TurbineConfig import os from os.path import join, isfile, realpath from numpy import array from time import time cfg = TurbineConfig.load('test/turbine_unittest.cfg') turbine = Turbine(cfg) import visualizer vis = visualizer.Visualizer(turbine.env) import blade_coverage import db grid = 7 robot = turbine.robot manip = robot.GetActiveManipulator() robot.GetLink('Flame').Enable(False) DB = db.DB(join(os.environ['PYTHON_DATABASE'], 'FACE'), turbine) T = turbine.blades[3].GetTransform() DB.T = T psa = (1.8500000000000032, 0.53725006964517363, 0.82546707480056725) threshold = 5e-2 t = time() path = blade_coverage.base_grid_validation(turbine, psa, DB, grid, threshold) print time() - t
def topology(): return Turbine(debug=True)
def curveClicked(self): if self.turbine.currentText() != '': Turbine(self.turbine.currentText()).PowerCurve() return
import numpy as np from numpy import pi, array, dot import matplotlib.pylab as plt import matplotlib.gridspec as gridspec import dynamics from turbine import Turbine # Options dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = False # Create model bladed_file = r"C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj" tb = Turbine(bladed_file, rigid=False) # Set base motion tb.system.free(tb.base) tb.system.prescribe(tb.base, acc=0, vel=0, part=[0, 1, 2, 3, 5]) # Define foundation matrix - no coupling for now # Choose to match appropriate frequencies of rigid-body motion (Karimirad & Moan, 2012) # in surge, sway, heave, roll, pitch yaw respectively rigid_body_freqs = array([0.05, 0.05, 0.20, 0.22, 0.22, 0.84]) ** 2 foundation = np.diag( [ tb.mass * rigid_body_freqs[0], tb.mass * rigid_body_freqs[1], tb.mass * rigid_body_freqs[2], tb.inertia[0, 0] * rigid_body_freqs[3],
import dynamics from turbine import Turbine # Turn off gravity dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = True # Parameters pitch_freq = 0.3 # rad/s pitch_amp = 0.3 # rad rotor_speed = 2 # rad/s # Create model bladed_file = r'C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj' tb = Turbine(bladed_file) tb.set_base_motion(4, pitch_freq, pitch_amp) # Simulate #t,y = tb.simulate(rotor_speed=2, t1=90, dt=0.10, init=True) def mbc(az, u): N = len(az) B = array([ np.ones((3,N)), [2*np.cos(az), 2*np.cos(az+2*pi/3), 2*np.cos(az+4*pi/3)], [2*np.sin(az), 2*np.sin(az+2*pi/3), 2*np.sin(az+4*pi/3)], ]) / 3 u = array(u) z = np.einsum('zbt,btj->jzt', B, u) return z
class Engine(Turbomachine): def __init__(self): self.compressor = Compressor() self.turbine = Turbine() self.initial_guess = self.__class__.DEFAULT_PARAMS.copy() self.cpc = 1004 # J/(kg K) self.cpt = 1225 # J/(kg K) self.T01 = 273.15 # K self.P01 = 101e3 # Pa self.R_c = (1 - 1 / self.compressor.gam) * self.cpc # from gam and cp self.R_t = (1 - 1 / self.turbine.gam) * self.cpt self.A8 = pi / 4 * 35e-3**2 # Measured: D8 = 45mm self.FHV = 43e6 #J/kg Fuel lower calorific value self.eta_combustion = 0.5 DEFAULT_PARAMS = { 'P0_ratio_c': 1.2347241010782356, 'Mb_t': 0.27072466251896482, 'MFP4': 0.15310678698124691, 'MFP3': 0.14924987675288623, 'M_flight': 0, 'mdotf': 0.0019637316313999187, 'P0_ratio_t': 0.92680225375718472, 'MFP5': 0.15451547834023707, 'Mb_c': 0.44527731422329964, 'MFP': 0.14801196525452109, 'T0_ratio_t': 0.98261102832775471, 'T0_ratio_c': 1.0669702796449636, 'T04': 840.63888888888891 } N_FREE_PARAMS = 2 def implicit_map( self, M_flight, # flight mach number MFP, MFP3, Mb_c, T0_ratio_c, P0_ratio_c, # compressor mdotf, T04, # burner MFP4, MFP5, Mb_t, T0_ratio_t, P0_ratio_t # turbine ): """ This function implements burner, nozzle and spool dynamics and integrates it with turbine and compressor maps Variable balance: 12 variables - 11 equations -------- 2 free choices (e.g. M_flight and mdotf) """ # Expose constants A8 = self.A8 FHV = self.FHV eta_combustion = self.eta_combustion A5 = self.turbine.geom['A2'] gam_c = self.compressor.gam gam_t = self.turbine.gam cpc = self.cpc cpt = self.cpt T01 = self.T01 P01 = self.P01 R_c = self.R_c R_t = self.R_t ### Dimensionalize everything ### dim_params = self.dimensionalize( M_flight, # flight mach number MFP, MFP3, Mb_c, T0_ratio_c, P0_ratio_c, # compressor mdotf, T04, # burner MFP4, MFP5, Mb_t, T0_ratio_t, P0_ratio_t # turbine ) T02 = dim_params.T02 T03 = dim_params.T03 T05 = dim_params.T05 P02 = dim_params.P02 P03 = dim_params.P03 P04 = dim_params.P04 P05 = dim_params.P05 omega_c = dim_params.omega_c omega_t = dim_params.omega_t mdot2 = dim_params.mdot2 mdot3 = dim_params.mdot3 mdot4 = dim_params.mdot4 mdot5 = dim_params.mdot5 ### CONSTRAINTS ### # * Energy addition in ther burner res_T04 = T03 + mdotf * FHV * eta_combustion / (mdot3 * cpc) - T04 # * Spool has constant speed res_omega = omega_c - omega_t # * Conservation of energy in the spool res_energy = mdot2 * cpc * (T03 - T02) - mdot4 * cpt * (T04 - T05) # * Consevation of mass in the combustor res_mdot = mdot3 + mdotf - mdot4 # * Nozzle exit is either choked or at ambient pressure Pa = P01 / (1 + (gam_c - 1) / 2 * M_flight**2)**(gam_c / (gam_c - 1)) MFP8 = MFP5 * A5 / A8 res_MFP_nozzle = (P05 / Pa - 1) * MFP8 - (P05 / Pa - 1) * mach2mfp( min(1, (2 / (gam_t - 1) * ((P05 / Pa)**( (gam_t - 1) / gam_t) - 1))**0.5) if P05 / Pa > 1 else 0, gam_t) ### remove dimensions of residuals ### # References for removing dimensions of residuals mdotref = (T01 * R_c)**0.5 / (P01 * gam_c**0.5 * self.compressor.geom['A1']) h_ref = cpc * T01 omega_ref = (gam_c * R_c * T01)**0.5 / self.compressor.geom['D2'] #remove dimensions res_omega /= omega_ref res_energy /= h_ref * mdotref res_mdot /= mdotref res_T04 /= T04 ### COMPRESSOR MAP ### res_MFP_c, res_T0_ratio_c, res_P0_ratio_c = self.compressor.implicit_map( MFP, MFP3, Mb_c, T0_ratio_c, P0_ratio_c, tol=1e-13) ### TURBINE MAP ### res_MFP_t, res_T0_ratio_t, res_P0_ratio_t = self.turbine.implicit_map( MFP4, MFP5, Mb_t, T0_ratio_t, P0_ratio_t, tol=1e-13) return (res_omega, res_energy, res_mdot, res_MFP_nozzle, res_T04, res_MFP_c, res_T0_ratio_c, res_P0_ratio_c, res_MFP_t, res_T0_ratio_t, res_P0_ratio_t) def dimensionalize( self, M_flight, # flight mach number MFP, MFP3, Mb_c, T0_ratio_c, P0_ratio_c, # compressor mdotf, T04, # burner MFP4, MFP5, Mb_t, T0_ratio_t, P0_ratio_t # turbine ): gam_c = self.compressor.gam gam_t = self.turbine.gam T01 = self.T01 P01 = self.P01 R_c = self.R_c R_t = self.R_t ### Dimensionalize everything ### a01 = (gam_c * R_c * T01)**0.5 a04 = (gam_t * R_t * T04)**0.5 T02 = T01 T03 = T02 * T0_ratio_c T04 = T04 T05 = T04 * T0_ratio_t P02 = P01 P03 = P02 * P0_ratio_c P04 = P03 P05 = P03 * P0_ratio_t omega_c = Mb_c * a01 / (self.compressor.geom['D2'] / 2) omega_t = Mb_t * a04 / (self.turbine.geom['D1t'] / 2) mdot2 = MFP * self.compressor.geom['A1'] * P01 * gam_c**0.5 / ( T01 * R_c)**0.5 mdot3 = MFP3 * self.compressor.geom['A2'] * P03 * gam_c**0.5 / ( T03 * R_c)**0.5 mdot4 = MFP4 * self.turbine.geom['A1'] * P04 * gam_t**0.5 / (T04 * R_t)**0.5 mdot5 = MFP5 * self.turbine.geom['A2'] * P05 * gam_t**0.5 / (T05 * R_t)**0.5 #Nozzle MFP8 = min(MFP5 * self.turbine.geom['A2'] / self.A8, mach2mfp(1, gam_t)) M8 = mfp2mach(MFP8, gam_t) P8 = P05 * (1 + (gam_t - 1) / 2 * M8**2)**(-gam_t / (gam_t - 1)) T8 = T05 * (1 + (gam_t - 1) / 2 * M8**2)**(-1) dim_params = DimensionalParameters(T02=T02, T03=T03, T04=T04, T05=T05, T8=T8, P02=P02, P03=P03, P04=P04, P05=P05, P8=P8, omega_c=omega_c, omega_t=omega_t, mdot2=mdot2, mdot3=mdot3, mdot4=mdot4, mdot5=mdot5) return dim_params def working_line(self, T04_grid): wline = [] params = self.initial_guess for T04 in T04_grid: sol = self.general_explicit_map({ 'M_flight': 0, 'T04': T04 }, params) params = sol.params wline.append(params) return wline def thrust(self, **params): gam_t = self.turbine.gam R_t = self.R_t MFP8 = min(params['MFP5'] * self.turbine.geom['A2'] / self.A8, mach2mfp(1, gam_t)) mdot = params['MFP5'] * self.turbine.geom['A2'] * params[ 'P05'] * gam_t**0.5 / (params['T05'] * R_t)**0.5 M8 = mfp2mach(MFP8, gam_t) P8 = params['P05'] * (1 + (gam_t - 1) / 2 * M8**2)**(-gam_t / (gam_t - 1)) mdot5 = params['MFP5'] * self.turbine.geom['A2'] * params[ 'P05'] * gam_t**0.5 / (params['T05'] * R_t)**0.5 T8 = params['T05'] * (1 + (gam_t - 1) / 2 * M8**2)**(-1) return mdot * M8 * (gam_t * R_t * T8)**0.5 + ( P8 - self.P01 / (1 + (gam_t - 1) * params['M_flight']**2)**0.5) * self.A8 def ode_fun(self, t, y): P4, mdot, omega = y self.compressor.explicit_map(mdot, omega) T04 = self.throtle(t, mdot, T03) self.turbine.explicit_map(P4, omega) P4_dot = a01**2 * (mdot - mdott) mdotdot = A1 / Lc * (P3 - P4) omega_dot = 1 / J * torque_t - torque_c return P4_dot, mdotdot, omega_dot
def main(): """Balance of plant of a boiling water nuclear reactor. Attributes ---------- end_time: float End of the flow time in SI unit. time_step: float Size of the time step between port communications in SI unit. use_mpi: bool If set to `True` use MPI otherwise use Python multiprocessing. """ # Preamble end_time = 30 * unit.minute time_step = 30.0 # seconds show_time = (True, 5 * unit.minute) use_mpi = False # True for MPI; False for Python multiprocessing plot_results = True # True for enabling plotting section below params = get_params() # parameters for BoP BWR #***************************************************************************** # Define Cortix system # System top level plant = Cortix(use_mpi=use_mpi, splash=True) # Network plant_net = plant.network = Network() params['start-time'] = 0 params['end-time'] = end_time #***************************************************************************** # Create reactor module reactor = BWR(params) reactor.name = 'BWR' reactor.save = True reactor.time_step = time_step reactor.end_time = end_time reactor.show_time = show_time # Add reactor module to network plant_net.module(reactor) #***************************************************************************** # Create turbine 1 module params['turbine_inlet_pressure'] = 2 params['turbine_outlet_pressure'] = 0.005 params['high_pressure_turbine'] = True #params_turbine = reactor.params #params_turbine.inlet_pressure = 2 #params.turbine_outlet_pressure = 0.5 turbine1 = Turbine(params) turbine1.name = 'High Pressure Turbine' turbine1.save = True turbine1.time_step = time_step turbine1.end_time = end_time # Add turbine 1 module to network plant_net.module(turbine1) #***************************************************************************** # Create condenser module params['steam flowrate'] = params['steam flowrate'] * 2 condenser = Condenser(params) condenser.name = 'Condenser' condenser.save = True condenser.time_step = time_step condenser.end_time = end_time plant_net.module(condenser) #***************************************************************************** # Create the BoP network connectivity plant_net.connect([reactor, 'coolant-outflow'], [turbine1, 'inflow']) plant_net.connect([turbine1, 'outflow-1'], [condenser, 'inflow-1']) plant_net.connect([condenser, 'outflow'], [reactor, 'coolant-inflow']) plant_net.draw() #***************************************************************************** # Run network dynamics simulation plant.run() #***************************************************************************** # Plot results if plot_results and (plant.use_multiprocessing or plant.rank == 0): # Reactor plots reactor = plant_net.modules[0] (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('neutron-dens') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('test-neutron-dens.png', dpi=300) (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('delayed-neutrons-cc') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('test-delayed-neutrons-cc.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('test-coolant-outflow-temp.png', dpi=300) (quant, time_unit) = reactor.reactor_phase.get_quantity_history('fuel-temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('test-fuel-temp.png', dpi=300) # Turbine1 plots turbine1 = plant_net.modules[1] (quant, time_unit) = turbine1.outflow_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Power') plt.grid() plt.savefig('test-turbine1-power.png', dpi=300) (quant, time_unit) = turbine1.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Outflow Temperature') plt.grid() plt.savefig('test-turbine1-outflow-temp.png', dpi=300) # Condenser graphs condenser = plant_net.modules[-1] (quant, time_unit) = condenser.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('test-condenser-outflow-temp.png', dpi=300) # Properly shutdown simulation plant.close()
from inlet import Inlet from fan import Fan from bypass import Bypass from compressor import Compressor from combustion import CombustionChamber from spool import Spool from turbine import Turbine ambient_conditions = FlowCondition(corrected_mass_flow=1400., mach=0.8, t_static=216., p_static=22632., station_number='1', medium='air') inlet = Inlet(ambient=ambient_conditions, eta=0.98) fan = Fan(inflow=inlet.outflow, eta=0.92, pressure_ratio=1.6, station_number='21') bypass = Bypass(inflow=fan.outflow, bypass_ratio=8.) lpc = Compressor(inflow=bypass.outflow_core, eta=0.9, pressure_ratio=1.4, station_number='25') hpc = Compressor(inflow=lpc.outflow, eta=0.9, pressure_ratio=19, station_number='3') combustor = CombustionChamber(inflow=hpc.outflow, eta=0.99, pressure_ratio=0.96, t_total_exit=1450.) lp_spool = Spool(compressor_in=(fan, lpc), eta=0.99) hp_spool = Spool(compressor_in=hpc, eta=0.99) hpt = Turbine(inflow=combustor.outflow, spool_in=hp_spool, eta=0.92, station_number='45') lpt = Turbine(inflow=hpt.outflow, spool_in=lp_spool, eta=0.92, station_number='5') nozzle_core = Nozzle(inflow=lpt.outflow, ambient=ambient_conditions, eta=0.98, nozzle_type='convergent', station_number=('7', '8')) nozzle_bypass = Nozzle(inflow=bypass.outflow_bypass, ambient=ambient_conditions, eta=0.98, nozzle_type='convergent', station_number=('16', '18')) print(nozzle_core.p_critical) print(nozzle_core.choked) print(nozzle_core.pressure_thrust) # print(obj.p_total) # print(obj.t_total)
import numpy as np from numpy import pi, array, dot import matplotlib.pylab as plt import matplotlib.gridspec as gridspec import dynamics from turbine import Turbine # Options dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = False # Create model bladed_file = r'C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj' tb = Turbine(bladed_file, rigid=False) # Set base motion tb.system.free(tb.base) tb.system.prescribe(tb.base, acc=0, vel=0, part=[0,1,2,3,5]) # Define foundation matrix - no coupling for now # Choose to match appropriate frequencies of rigid-body motion (Karimirad & Moan, 2012) # in surge, sway, heave, roll, pitch yaw respectively rigid_body_freqs = array([0.05, 0.05, 0.20, 0.22, 0.22, 0.84]) **2 foundation = np.diag([ tb.mass * rigid_body_freqs[0], tb.mass * rigid_body_freqs[1], tb.mass * rigid_body_freqs[2], tb.inertia[0,0] * rigid_body_freqs[3], tb.inertia[1,1] * rigid_body_freqs[4],
def main(): # Debugging make_plots = False make_run = False # Preamble end_time = 75 * unit.minute time_step = 1.5 * unit.second show_time = (True, 5 * unit.minute) plant = Cortix(use_mpi=False, splash=True) # System top level plant_net = plant.network = Network() # Network # Reactor reactor = SMPWR() # Create reactor module reactor.name = "SM-PWR" reactor.shutdown = (True, 60 * unit.minute) plant_net.module(reactor) # Add reactor module to network # Steamer steamer = Steamer() # Create reactor module plant_net.module(steamer) # Add steamer module to network # Turbine turbine = Turbine() # Create reactor module plant_net.module(turbine) # Add steamer module to network '''Condenser''' condenser = Condenser() # Create condenser module plant_net.module(condenser) # Add condenser module to network` '''Feedwater Heating system''' water_heater = WaterHeater() # Create water_heater module water_heater.malfunction = (True, 30 * unit.minute, 45 * unit.minute) plant_net.module(water_heater) # Add water_heater module to network # Balance of Plant Network Connectivity plant_net.connect([reactor, 'coolant-outflow'], [steamer, 'primary-inflow']) plant_net.connect([steamer, 'primary-outflow'], [reactor, 'coolant-inflow']) plant_net.connect([steamer, 'secondary-outflow'], [turbine, 'inflow']) plant_net.connect([turbine, 'outflow'], [condenser, 'inflow']) plant_net.connect([turbine, 'process-heat'], [water_heater, 'external-heat']) plant_net.connect([condenser, 'outflow'], [water_heater, 'inflow']) plant_net.connect([water_heater, 'outflow'], [steamer, 'secondary-inflow']) plant_net.draw(engine='circo', node_shape='folder') # Run if make_run: for module in plant_net.modules: module.time_step = time_step module.end_time = end_time module.show_time = show_time plant.run() # Run network dynamics simulation # Cortix run closure plant.close() # Properly shutdow plant # Plots if make_plots and plant.use_multiprocessing or plant.rank == 0: # Reactor plots reactor = plant_net.modules[0] (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('neutron-dens') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / max(quant.value), x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-neutron-dens.png', dpi=300) (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('delayed-neutrons-cc') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-delayed-neutrons-cc.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('reactor-coolant-outflow-temp.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('core-temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('reactor-core-temp.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + ' [M' + quant.unit + ']') plt.grid() plt.savefig('reactor-power.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('reynolds') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + r' [$\times 10^6$' + quant.unit + ']') plt.grid() plt.savefig('reactor-reynolds.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('prandtl') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + r' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-prandtl.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('flowrate') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + r' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-flowrate.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('heatflux') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + ' [M' + quant.unit + ']') plt.grid() plt.savefig('reactor-heatflux.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('inlet-temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('reactor-coolant-inflow-temp.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('nusselt') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-nusselt.png', dpi=300) (quant, time_unit) = reactor.state_phase.get_quantity_history('tau') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-coolant-tau.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('quality') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + r' [' + quant.unit + ']') plt.grid() plt.savefig('reactor-coolant-outflow-quality.png', dpi=300) # Steamer plots steamer = plant_net.modules[1] (quant, time_unit ) = steamer.primary_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('steamer-primary-outflow-temp.png', dpi=300) (quant, time_unit ) = steamer.secondary_inflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('steamer-secondary-inflow-temp.png', dpi=300) (quant, time_unit ) = steamer.secondary_inflow_phase.get_quantity_history('flowrate') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-secondary-inflow-flowrate.png', dpi=300) (quant, time_unit ) = steamer.secondary_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('steamer-secondary-outflow-temp.png', dpi=300) (quant, time_unit ) = steamer.secondary_outflow_phase.get_quantity_history('flowrate') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-secondary-outflow-flowrate.png', dpi=300) (quant, time_unit) = steamer.state_phase.get_quantity_history('tau_p') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-primary-tau.png', dpi=300) (quant, time_unit) = steamer.state_phase.get_quantity_history('tau_s') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-secondary-tau.png', dpi=300) (quant, time_unit ) = steamer.secondary_outflow_phase.get_quantity_history('quality') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-secondary-quality.png', dpi=300) (quant, time_unit) = steamer.state_phase.get_quantity_history('heatflux') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.kilo, x_label='Time [m]', y_label=quant.latex_name + ' [k' + quant.unit + ']') plt.grid() plt.savefig('steamer-heatflux.png', dpi=300) (quant, time_unit) = steamer.state_phase.get_quantity_history('nusselt_p') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-nusselt_p.png', dpi=300) (quant, time_unit) = steamer.state_phase.get_quantity_history('nusselt_s') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('steamer-nusselt_s.png', dpi=300) # Turbine plots turbine = plant_net.modules[2] (quant, time_unit) = turbine.state_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + ' [M' + quant.unit + ']') plt.grid() plt.savefig('turbine-power.png', dpi=300) (quant, time_unit) = turbine.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('turbine-outflow-temp.png', dpi=300) (quant, time_unit) = turbine.state_phase.get_quantity_history('rejected-heat') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + ' [M' + quant.unit + ']') plt.grid() plt.savefig('turbine-rejected-heat.png', dpi=300) # Condenser plots condenser = plant_net.modules[3] (quant, time_unit) = condenser.inflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('condenser-inflow-temp.png', dpi=300) (quant, time_unit) = condenser.inflow_phase.get_quantity_history('flowrate') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('condenser-inflow-flowrate.png', dpi=300) (quant, time_unit) = condenser.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('condenser-outflow-temp.png', dpi=300) # Water heater plots water_heater = plant_net.modules[4] (quant, time_unit) = water_heater.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, y_shift=273.15, x_label='Time [m]', y_label=quant.latex_name + ' [C]') plt.grid() plt.savefig('water_heater-outflow-temp.png', dpi=300) (quant, time_unit ) = water_heater.outflow_phase.get_quantity_history('flowrate') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + r' [' + quant.unit + ']') plt.grid() plt.savefig('water_heater-flowrate.png', dpi=300) (quant, time_unit ) = water_heater.inflow_phase.get_quantity_history('external-heat') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + r' [M' + quant.unit + ']') plt.grid() plt.savefig('water_heater-external-heat.png', dpi=300) (quant, time_unit ) = water_heater.outflow_phase.get_quantity_history('rejected-heat') quant.plot(x_scaling=1 / unit.minute, y_scaling=1 / unit.mega, x_label='Time [m]', y_label=quant.latex_name + r' [M' + quant.unit + ']') plt.grid() plt.savefig('water_heater-rejected-heat.png', dpi=300)
def main(): """Balance of plant of a boiling water nuclear reactor. Attributes ---------- end_time: float End of the flow time in SI unit. time_step: float Size of the time step between port communications in SI unit. use_mpi: bool If set to `True` use MPI otherwise use Python multiprocessing. """ # Preamble end_time = 30.0 * unit.minute time_step = 30.0 # seconds show_time = (True, 5 * unit.minute) use_mpi = False # True for MPI; False for Python multiprocessing plot_results = True # True for enabling plotting section below params = get_params() # parameters for BoP BWR #***************************************************************************** # Define Cortix system # System top level plant = Cortix(use_mpi=use_mpi, splash=True) # Network plant_net = plant.network = Network() params['start-time'] = 0.0 params['end-time'] = end_time params['shutdown-time'] = 999.0 * unit.hour params['shutdown-mode'] = False #***************************************************************************** # Create reactor module reactor = BWR(params) reactor.name = 'BWR' reactor.save = True reactor.time_step = time_step reactor.end_time = end_time reactor.show_time = show_time reactor.RCIS = True # Add reactor module to network plant_net.module(reactor) #***************************************************************************** # Create turbine high pressure module params['turbine_inlet_pressure'] = 2 params['turbine_outlet_pressure'] = 0.5 params['high_pressure_turbine'] = True #params_turbine = reactor.params #params_turbine.inlet_pressure = 2 #params.turbine_outlet_pressure = 0.5 turbine_hp = Turbine(params) turbine_hp.name = 'High Pressure Turbine' turbine_hp.save = True turbine_hp.time_step = time_step turbine_hp.end_time = end_time # Add turbine high pressure module to network plant_net.module(turbine_hp) #***************************************************************************** # Create turbine low pressure module params['turbine_inlet_pressure'] = 0.5 params['turbine_outlet_pressure'] = 0.005 params['high_pressure_turbine'] = False params['steam flowrate'] = params['steam flowrate'] / 2 turbine_lp1 = Turbine(params) turbine_lp1.name = 'Low Pressure Turbine 1' turbine_lp1.save = True turbine_lp1.time_step = time_step turbine_lp1.end_time = end_time plant_net.module(turbine_lp1) #***************************************************************************** # Create turbine low pressure module params['turbine_inlet_pressure'] = 0.5 params['turbine_outlet_pressure'] = 0.005 params['high_pressure_turbine'] = False turbine_lp2 = Turbine(params) turbine_lp2.name = 'Low Pressure Turbine 2' turbine_lp2.save = True turbine_lp2.time_step = time_step turbine_lp2.end_time = end_time plant_net.module(turbine_lp2) #***************************************************************************** # Create condenser module params['steam flowrate'] = params['steam flowrate'] * 2 condenser = Condenser() condenser.name = 'Condenser' condenser.save = True condenser.time_step = time_step condenser.end_time = end_time plant_net.module(condenser) #***************************************************************************** params['RCIS-shutdown-time'] = 5 * unit.minute rcis = Cooler(params) rcis.name = 'RCIS' rcis.save = True rcis.time_step = time_step rcis.end_time = end_time plant_net.module(rcis) #***************************************************************************** # Create the BoP network connectivity plant_net.connect([reactor, 'coolant-outflow'], [turbine_hp, 'inflow']) plant_net.connect([turbine_hp, 'outflow-1'], [turbine_lp1, 'inflow']) plant_net.connect([turbine_hp, 'outflow-2'], [turbine_lp2, 'inflow']) plant_net.connect([turbine_lp1, 'outflow-1'], [condenser, 'inflow-1']) plant_net.connect([turbine_lp2, 'outflow-1'], [condenser, 'inflow-2']) plant_net.connect([condenser, 'outflow'], [reactor, 'coolant-inflow']) plant_net.connect([reactor, 'RCIS-outflow'], [rcis, 'coolant-inflow']) plant_net.connect([rcis, 'coolant-outflow'], [reactor, 'RCIS-inflow']) #plant_net.connect([rcis, 'signal-in'], [reactor, 'signal-out']) plant_net.draw(engine='dot', node_shape='folder') #***************************************************************************** # Run network dynamics simulation plant.run() #***************************************************************************** # Plot results if plot_results and (plant.use_multiprocessing or plant.rank == 0): # Reactor plots reactor = plant_net.modules[0] (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('neutron-dens') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('startup-neutron-dens.png', dpi=300) (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('delayed-neutrons-cc') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('startup-delayed-neutrons-cc.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('startup-coolant-outflow-temp.png', dpi=300) (quant, time_unit) = reactor.reactor_phase.get_quantity_history('fuel-temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('startup-fuel-temp.png', dpi=300) # Turbine high pressure plots turbine_hp = plant_net.modules[1] (quant, time_unit) = turbine_hp.outflow_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Power') plt.grid() plt.savefig('startup-turbine-hp-power.png', dpi=300) (quant, time_unit) = turbine_hp.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Outflow Temperature') plt.grid() plt.savefig('startup-turbine-hp-outflow-temp.png', dpi=300) # Turbine low pressure graphs turbine_lp1 = plant_net.modules[2] (quant, time_unit) = turbine_lp1.outflow_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='Lower Pressure Turbine 1 Power') plt.grid() plt.savefig('startup-turbine-lp1-power.png', dpi=300) (quant, time_unit) = turbine_lp1.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='Lower Pressure Turbine 1 Outflow Temperature') plt.grid() plt.savefig('startup-turbine-lp1-outflow-temp.png', dpi=300) # Condenser graphs condenser = plant_net.modules[3] (quant, time_unit) = condenser.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('startup-condenser-outflow-temp.png', dpi=300) #setup initial values for simulation turbine1_outflow_temp = turbine_hp.outflow_phase.get_value( 'temp', end_time) turbine1_chi = turbine_hp.outflow_phase.get_value('quality', end_time) turbine1_power = turbine_hp.outflow_phase.get_value('power', end_time) turbine2_outflow_temp = turbine_lp1.outflow_phase.get_value( 'temp', end_time) turbine2_chi = turbine_lp1.outflow_phase.get_value('quality', end_time) turbine2_power = turbine_lp1.outflow_phase.get_value('power', end_time) condenser_runoff_temp = condenser.outflow_phase.get_value('temp', end_time) delayed_neutron_cc = reactor.neutron_phase.get_value( 'delayed-neutrons-cc', end_time) n_dens = reactor.neutron_phase.get_value('neutron-dens', end_time) fuel_temp = reactor.reactor_phase.get_value('fuel-temp', end_time) coolant_temp = reactor.coolant_outflow_phase.get_value('temp', end_time) # Values loaded into params when they are needed (module instantiation) # Properly shutdown simulation plant.close() # Now we run shutdown as a seperate simulation with starting parameters equal to the ending # values of the startup simulation #************************************************************************************************** # Preamble start_time = 0.0 * unit.minute end_time = 60 * unit.minute time_step = 30.0 # seconds show_time = (True, 5 * unit.minute) use_mpi = False # True for MPI; False for Python multiprocessing plot_results = True # True for enabling plotting section below params = get_params() # clear params, just to be safe #***************************************************************************** # Define Cortix system # System top level plant = Cortix(use_mpi=use_mpi, splash=True) # Network plant_net = plant.network = Network() params['start-time'] = start_time params['end-time'] = end_time params['shutdown time'] = 0.0 params['shutdown-mode'] = True #***************************************************************************** # Create reactor module params['delayed-neutron-cc'] = delayed_neutron_cc params['n-dens'] = n_dens params['fuel-temp'] = fuel_temp params['coolant-temp'] = coolant_temp params['operating-mode'] = 'shutdown' reactor = BWR(params) reactor.name = 'BWR' reactor.save = True reactor.time_step = time_step reactor.end_time = end_time reactor.show_time = show_time reactor.RCIS = False # Add reactor module to network plant_net.module(reactor) #***************************************************************************** # Create turbine high pressure module params['turbine_inlet_pressure'] = 2 params['turbine_outlet_pressure'] = 0.5 params['high_pressure_turbine'] = True params['turbine-outflow-temp'] = turbine1_outflow_temp params['turbine-chi'] = turbine1_chi params['turbine-work'] = turbine1_power params['turbine-inflow-temp'] = coolant_temp #params_turbine = reactor.params #params_turbine.inlet_pressure = 2 #params.turbine_outlet_pressure = 0.5 turbine_hp = Turbine(params) turbine_hp.name = 'High Pressure Turbine' turbine_hp.save = True turbine_hp.time_step = time_step turbine_hp.end_time = end_time # Add turbine high pressure module to network plant_net.module(turbine_hp) #***************************************************************************** # Create turbine low pressure 1 module params['turbine_inlet_pressure'] = 0.5 params['turbine_outlet_pressure'] = 0.005 params['high_pressure_turbine'] = False params['steam flowrate'] = params['steam flowrate'] / 2 params['turbine-outflow-temp'] = turbine2_outflow_temp params['turbine-inflow-temp'] = turbine1_outflow_temp params['turbine-chi'] = turbine2_chi params['turbine-work'] = turbine2_power turbine_lp1 = Turbine(params) turbine_lp1.name = 'Low Pressure Turbine 1' turbine_lp1.save = True turbine_lp1.time_step = time_step turbine_lp1.end_time = end_time plant_net.module(turbine_lp1) #***************************************************************************** # Create turbine low pressure 2 module params['turbine_inlet_pressure'] = 0.5 params['turbine_outlet_pressure'] = 0.005 params['high_pressure_turbine'] = False turbine_lp2 = Turbine(params) turbine_lp2.name = 'Low Pressure Turbine 2' turbine_lp2.save = True turbine_lp2.time_step = time_step turbine_lp2.end_time = end_time plant_net.module(turbine_lp2) #***************************************************************************** # Create condenser module params['steam flowrate'] = params['steam flowrate'] * 2 params['condenser-runoff-temp'] = condenser_runoff_temp condenser = Condenser() condenser.name = 'Condenser' condenser.save = True condenser.time_step = time_step condenser.end_time = end_time plant_net.module(condenser) #***************************************************************************** params['RCIS-shutdown-time'] = -1 * unit.minute rcis = Cooler(params) rcis.name = 'RCIS' rcis.save = True rcis.time_step = time_step rcis.end_time = end_time plant_net.module(rcis) #***************************************************************************** # Create the BoP network connectivity plant_net.connect([reactor, 'coolant-outflow'], [turbine_hp, 'inflow']) plant_net.connect([turbine_hp, 'outflow-1'], [turbine_lp1, 'inflow']) plant_net.connect([turbine_hp, 'outflow-2'], [turbine_lp2, 'inflow']) plant_net.connect([turbine_lp1, 'outflow-1'], [condenser, 'inflow-1']) plant_net.connect([turbine_lp2, 'outflow-1'], [condenser, 'inflow-2']) plant_net.connect([condenser, 'outflow'], [reactor, 'coolant-inflow']) plant_net.connect([reactor, 'RCIS-outflow'], [rcis, 'coolant-inflow']) plant_net.connect([rcis, 'coolant-outflow'], [reactor, 'RCIS-inflow']) #plant_net.connect([rcis, 'signal-in'], [reactor, 'signal-out']) plant_net.draw(engine='dot', node_shape='folder') #***************************************************************************** # Run network dynamics simulation plant.run() #***************************************************************************** # Plot results if plot_results and (plant.use_multiprocessing or plant.rank == 0): # Reactor plots reactor = plant_net.modules[0] (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('neutron-dens') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('shutdown-neutron-dens.png', dpi=300) (quant, time_unit ) = reactor.neutron_phase.get_quantity_history('delayed-neutrons-cc') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('shutdown-delayed-neutrons-cc.png', dpi=300) (quant, time_unit ) = reactor.coolant_outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('shutdown-coolant-outflow-temp.png', dpi=300) (quant, time_unit) = reactor.reactor_phase.get_quantity_history('fuel-temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('shutdown-fuel-temp.png', dpi=300) # Turbine high pressure plots turbine_hp = plant_net.modules[1] (quant, time_unit) = turbine_hp.outflow_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Power') plt.grid() plt.savefig('shutdown-turbine-hp-power.png', dpi=300) (quant, time_unit) = turbine_hp.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='High Pressure Turbine Outflow Temperature') plt.grid() plt.savefig('shutdown-turbine-hp-outflow-temp.png', dpi=300) # Turbine low pressure graphs turbine_lp1 = plant_net.modules[2] (quant, time_unit) = turbine_lp1.outflow_phase.get_quantity_history('power') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='Lower Pressure Turbine 1 Power') plt.grid() plt.savefig('shutdown-turbine-lp1-power.png', dpi=300) (quant, time_unit) = turbine_lp1.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']', title='Lower Pressure Turbine 1 Outflow Temperature') plt.grid() plt.savefig('shutdown-turbine-lp1-outflow-temp.png', dpi=300) # Condenser graphs condenser = plant_net.modules[4] (quant, time_unit) = condenser.outflow_phase.get_quantity_history('temp') quant.plot(x_scaling=1 / unit.minute, x_label='Time [m]', y_label=quant.latex_name + ' [' + quant.unit + ']') plt.grid() plt.savefig('shutdown-condenser-outflow-temp.png', dpi=300) # Shutdown The Simulation plant.close()
def __init__(self, dialog, anobject, scenarios=None): super(AnObject, self).__init__() self.get_config() self.anobject = anobject if scenarios is not None: self.scenarios = [] for i in range(len(scenarios)): if scenarios[i][0] != 'Existing': self.scenarios.append(scenarios[i][0]) if len(self.scenarios) < 2: self.scenarios = None else: self.scenarios = None dialog.setObjectName('Dialog') self.save = False self.field = ['name', 'technology', 'lat', 'lon', 'capacity', 'turbine', 'rotor', 'no_turbines', 'area', 'scenario', 'power_file', 'grid_line', 'storage_hours', 'direction', 'tilt', 'zone'] self.label = [] self.edit = [] self.field_type = [] metrics = [] widths = [0, 0] heights = 0 self.turbines = [['', '', 0., 0.]] # name, class, rotor, size # self.turbine_class = [''] grid = QtWidgets.QGridLayout() turbcombo = QtWidgets.QComboBox(self) if os.path.exists(self.sam_file): sam = open(self.sam_file) sam_turbines = csv.DictReader(sam) for turb in sam_turbines: if turb['Name'] == 'Units' or turb['Name'] == '[0]': pass else: self.turbines.append([turb['Name'].strip(), '', turb['Rotor Diameter'], float(turb['KW Rating'])]) if turb['IEC Wind Speed Class'] in ['', ' ', '0', 'Unknown', 'unknown', 'not listed']: pass else: cls = turb['IEC Wind Speed Class'].replace('|', ', ') cls.replace('Class ', '') self.turbines[-1][1] = 'Class: ' + cls sam.close() if os.path.exists(self.pow_dir): pow_files = os.listdir(self.pow_dir) for name in pow_files: if name[-4:] == '.pow': turb = Turbine(name[:-4]) if name == 'Enercon E40.pow': size = 600. else: size = 0. bits = name.lower().split('kw') if len(bits) > 1: bit = bits[0].strip() for i in range(len(bit) -1, -1, -1): if not bit[i].isdigit() and not bit[i] == '.': break size = float(bit[i + 1:]) else: bits = name.lower().split('mw') if len(bits) > 1: bit = bits[0].strip() for i in range(len(bit) -1, -1, -1): if not bit[i].isdigit() and not bit[i] == '.': break size = float(bit[i + 1:]) * 1000 else: for i in range(len(name) -4, -1, -1): if not name[i].isdigit() and not name[i] == '.': break try: size = float(name[i + 1: -4]) except: pass self.turbines.append([name[:-4], '', str(turb.rotor), size]) self.turbines.sort() self.turbines_sorted = True got_turbine = False j = 0 # in case no Vestas V90-2.0 for i in range(len(self.turbines)): if self.turbines[i][0] == 'Vestas V90-2.0': j = i turbcombo.addItem(self.turbines[i][0]) if self.turbines[i][0] == self.anobject.turbine: turbcombo.setCurrentIndex(i) if self.turbines[i][0] != '': got_turbine = True if not got_turbine: turbcombo.setCurrentIndex(j) techcombo = QtWidgets.QComboBox(self) for i in range(len(self.technologies)): techcombo.addItem(self.technologies[i]) if self.technologies[i] == self.anobject.technology: techcombo.setCurrentIndex(i) if self.scenarios is not None: scencombo = QtWidgets.QComboBox(self) for i in range(len(self.scenarios)): scencombo.addItem(self.scenarios[i]) if self.scenarios[i] == self.anobject.scenario: scencombo.setCurrentIndex(i) for i in range(len(self.field)): if self.field[i] == 'turbine': self.label.append(ClickableQLabel(self.field[i].title() + ': (Name order)')) self.label[-1].setStyleSheet("background-color: white; border: 1px inset grey; min-height: 22px; border-radius: 4px;") self.label[-1].clicked.connect(self.turbineSort) else: self.label.append(QtWidgets.QLabel(self.field[i].title() + ':')) if i == 0: metrics.append(self.label[-1].fontMetrics()) if metrics[0].boundingRect(self.label[-1].text()).width() > widths[0]: widths[0] = metrics[0].boundingRect(self.label[-1].text()).width() grid.addWidget(self.label[-1], i + 1, 0) self.capacity_was = 0.0 self.no_turbines_was = 0 self.turbine_was = '' self.turbine_classd = QtWidgets.QLabel('') self.show_hide = {} units = {'area': 'sq. Km', 'capacity': 'MW'} for i in range(len(self.field)): try: attr = getattr(self.anobject, self.field[i]) except: attr = '' if isinstance(attr, int): self.field_type.append('int') elif isinstance(attr, float): self.field_type.append('float') else: self.field_type.append('str') if self.field[i] == 'name': self.name = attr self.edit.append(QtWidgets.QLineEdit(self.name)) metrics.append(self.label[-1].fontMetrics()) elif self.field[i] == 'technology': self.techcomb = techcombo self.edit.append(self.techcomb) self.techcomb.currentIndexChanged.connect(self.technologyChanged) elif self.field[i] == 'lat': self.lat = attr self.edit.append(QtWidgets.QLineEdit(str(self.lat))) elif self.field[i] == 'lon': self.lon = attr self.edit.append(QtWidgets.QLineEdit(str(self.lon))) elif self.field[i] == 'capacity': self.capacity = attr self.capacity_was = attr self.edit.append(QtWidgets.QDoubleSpinBox()) # QtWidgets.QLineEdit(str(self.capacity))) self.edit[-1].setRange(0, 10000) self.edit[-1].setValue(self.capacity) self.edit[-1].setDecimals(3) elif self.field[i] == 'turbine': if self.techcomb.currentText().find('Wind') < 0 \ and self.techcomb.currentText().find('Offshore') < 0 \ and self.techcomb.currentText() != '': turbcombo.setCurrentIndex(0) self.turbine = turbcombo self.turbines_was = turbcombo self.show_hide['turbine'] = len(self.edit) self.edit.append(self.turbine) self.turbine_classd.setText(self.turbines[turbcombo.currentIndex()][1]) self.turbine.currentIndexChanged.connect(self.turbineChanged) grid.addWidget(self.turbine_classd, i + 1, 2) elif self.field[i] == 'rotor': self.rotor = attr self.show_hide['rotor'] = len(self.edit) self.edit.append(QtWidgets.QLineEdit(str(self.rotor))) self.edit[-1].setEnabled(False) self.curve = QtWidgets.QPushButton('Show Power Curve', self) grid.addWidget(self.curve, i + 1, 2) self.curve.clicked.connect(self.curveClicked) elif self.field[i] == 'no_turbines': self.no_turbines = attr self.no_turbines_was = attr self.show_hide['no_turbines'] = len(self.edit) self.edit.append(QtWidgets.QSpinBox()) # QtWidgets.QLineEdit(str(self.no_turbines))) self.edit[-1].setRange(0, 299) if self.no_turbines == '': self.edit[-1].setValue(0) else: self.edit[-1].setValue(int(self.no_turbines)) elif self.field[i] == 'area': self.area = attr self.edit.append(QtWidgets.QLineEdit(str(self.area))) self.edit[-1].setEnabled(False) elif self.field[i] == 'scenario': self.scenario = attr if self.scenarios is None: self.edit.append(QtWidgets.QLineEdit(self.scenario)) self.edit[-1].setEnabled(False) else: self.scencomb = scencombo self.scencomb.currentIndexChanged.connect(self.scenarioChanged) self.edit.append(self.scencomb) elif self.field[i] == 'power_file': self.power_file = attr self.edit.append(QtWidgets.QLineEdit(self.power_file)) elif self.field[i] == 'grid_line': self.grid_line = attr if attr is not None: self.edit.append(QtWidgets.QLineEdit(self.grid_line)) else: self.edit.append(QtWidgets.QLineEdit('')) elif self.field[i] == 'storage_hours': self.storage_hours = attr self.show_hide['storage_hours'] = len(self.edit) if attr is not None: self.edit.append(QtWidgets.QLineEdit(str(self.storage_hours))) else: try: if self.techcomb.currentText() == 'CST': self.edit.append(QtWidgets.QLineEdit(str(self.cst_tshours))) else: self.edit.append(QtWidgets.QLineEdit(str(self.st_tshours))) except: pass elif self.field[i] == 'direction': self.direction = attr self.show_hide['direction'] = len(self.edit) if attr is not None: self.edit.append(QtWidgets.QLineEdit(str(self.direction))) else: self.edit.append(QtWidgets.QLineEdit('')) elif self.field[i] == 'tilt': self.tilt = attr self.show_hide['tilt'] = len(self.edit) if attr is not None: self.edit.append(QtWidgets.QLineEdit(str(self.tilt))) else: self.edit.append(QtWidgets.QLineEdit('')) elif self.field[i] == 'zone': self.zone = attr self.show_hide['zone'] = len(self.edit) if attr is not None: self.edit.append(QtWidgets.QLineEdit(str(self.zone))) else: self.edit.append(QtWidgets.QLineEdit('')) self.edit[-1].setEnabled(False) try: if metrics[1].boundingRect(self.edit[-1].text()).width() > widths[1]: widths[1] = metrics[1].boundingRect(self.edit[-1].text()).width() except: pass grid.addWidget(self.edit[-1], i + 1, 1) if self.field[i] in list(units.keys()): grid.addWidget(QtWidgets.QLabel(units[self.field[i]]), i + 1, 2) self.technologyChanged(self.techcomb.currentIndex) grid.setColumnMinimumWidth(0, widths[0] + 10) grid.setColumnMinimumWidth(1, widths[1] + 10) grid.setColumnMinimumWidth(2, 30) i += 1 self.message = QtWidgets.QLabel('') msg_font = self.message.font() msg_font.setBold(True) self.message.setFont(msg_font) msg_palette = QtGui.QPalette() msg_palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red) self.message.setPalette(msg_palette) grid.addWidget(self.message, i + 1, 0, 1, 2) i += 1 quit = QtWidgets.QPushButton("Quit", self) grid.addWidget(quit, i + 1, 0) quit.clicked.connect(self.quitClicked) save = QtWidgets.QPushButton("Save && Exit", self) grid.addWidget(save, i + 1, 1) save.clicked.connect(self.saveClicked) self.setLayout(grid) self.resize(widths[0] + widths[1] + 40, heights * i) self.setWindowTitle('SIREN - Edit ' + getattr(self.anobject, '__module__')) QtWidgets.QShortcut(QtGui.QKeySequence("q"), self, self.quitClicked)
import dynamics from turbine import Turbine # Turn off gravity dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = True # Parameters pitch_freq = 0.3 # rad/s pitch_amp = 0.3 # rad rotor_speed = 2 # rad/s # Create model bladed_file = r'C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj' tb = Turbine(bladed_file) # Linearise model and simulate lin = tb.lin(az0=0, rotor_speed=rotor_speed, init=True) t,yl = lin.integrate(90) # Convert to MBC and simulate mbclin = lin.multiblade_transform((0, rotor_speed), [range(0,4),range(4,8),range(8,12)]) t,ym = mbclin.integrate(90) # Simulate original full system #t,y = tb.simulate(rotor_speed=2, t1=90, dt=0.10, init=True) def mbc(az, u): N = len(az)
def saveClicked(self): for i in range(len(self.field)): try: if not self.edit[i].isEnabled(): continue except: continue self.edit[i].setFocus() if isinstance(self.edit[i], QtWidgets.QLineEdit): if self.field[i] == 'direction' and 'PV' in self.technology: try: setattr(self, self.field[i], int(self.edit[i].text())) if self.direction < 0: self.direction = 360 + self.direction if self.direction > 360: self.message.setText('Error with ' + self.field[i].title() + ' field') return except: setattr(self, self.field[i], self.edit[i].text()) if self.direction.upper() in ['', 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']: self.direction = self.direction.upper() else: self.message.setText('Error with ' + self.field[i].title() + ' field') return if self.field[i] == 'tilt' and 'PV' in self.technology: try: setattr(self, self.field[i], float(self.edit[i].text())) if self.tilt < -180. or self.tilt > 180.: self.message.setText('Error with ' + self.field[i].title() + ' field') return except: pass elif self.field_type[i] == 'int': try: setattr(self, self.field[i], int(self.edit[i].text())) except: self.message.setText('Error with ' + self.field[i].title() + ' field') return elif self.field_type[i] == 'float': try: setattr(self, self.field[i], float(self.edit[i].text())) if self.field[i] == 'lon': if self.lon < self.upper_left[1]: self.message.setText('Error with ' + self.field[i].title() + ' field. Too far west') return elif self.lon > self.lower_right[1]: self.message.setText('Error with ' + self.field[i].title() + ' field. Too far east') return elif self.field[i] == 'lat': if self.lat > self.upper_left[0]: self.message.setText('Error with ' + self.field[i].title() + ' field. Too far north') return elif self.lat < self.lower_right[0]: self.message.setText('Error with ' + self.field[i].title() + ' field. Too far south') return except: self.message.setText('Error with ' + self.field[i].title() + ' field') return elif self.field[i] == 'grid_line': if self.edit[i].text() == '': setattr(self, self.field[i], None) else: setattr(self, self.field[i], self.edit[i].text()) else: setattr(self, self.field[i], self.edit[i].text()) elif isinstance(self.edit[i], QtWidgets.QComboBox): setattr(self, self.field[i], self.edit[i].currentText()) if self.field[i] == 'technology' and self.edit[i].currentText() == '': self.message.setText('Error with ' + self.field[i].title() + '. Choose technology') return elif isinstance(self.edit[i], QtWidgets.QDoubleSpinBox): setattr(self, self.field[i], self.edit[i].value()) elif isinstance(self.edit[i], QtWidgets.QSpinBox): setattr(self, self.field[i], self.edit[i].value()) if self.technology.find('Wind') < 0 and self.technology.find('Offshore') < 0: self.rotor = 0.0 self.turbine == '' if self.technology == 'Biomass': self.area = self.areas[self.technology] * float(self.capacity) elif 'PV' in self.technology: self.area = self.areas[self.technology] * float(self.capacity) elif self.technology.find('Wind') >= 0 or self.technology.find('Offshore') >= 0: if self.turbine == '': self.edit[5].setFocus() self.message.setText('Error with ' + self.field[5].title() + '. Choose turbine') return turbine = Turbine(self.turbine) if self.capacity != self.capacity_was or \ (self.turbine != self.turbine_was and self.no_turbines == self.no_turbines_was): self.no_turbines = int(round((self.capacity * 1000.) / turbine.capacity)) self.capacity = self.no_turbines * turbine.capacity / 1000. # reduce from kW to MW self.rotor = turbine.rotor self.area = self.areas[self.technology] * float(self.no_turbines) * pow((self.rotor * .001), 2) elif self.technology in ['CST', 'Solar Thermal']: self.area = self.areas[self.technology] * float(self.capacity) # temp calc. Should be 3.83 x collector area elif self.technology == 'Geothermal': self.area = self.areas[self.technology] * float(self.capacity) elif self.technology == 'Wave': self.area = self.areas[self.technology] * float(self.capacity) elif self.technology == 'Hydro': self.area = self.areas[self.technology] * float(self.capacity) elif self.technology[:5] == 'Other': self.area = self.areas[self.technology] * float(self.capacity) else: self.message.setText('This technology not yet implemented. Choose another.') self.edit[1].setFocus() return self.save = True self.close()
from turbine import Turbine topology = Turbine(debug=True) @topology.source("input") def add_exclamation(input_str): return input_str + "!" @topology.scatter("input", ["output_1", "output_2"], num_tasks=1) def moar_exclamations(input_str): return input_str + "!!" @topology.sink("output_1") def print_val(val): print(val) @topology.sink("output_2", num_tasks=2) def print_val2(val): print(val.upper()) values = ["hello", "world"] topology.run(values)
from turbine_config import TurbineConfig, ConfigFileError from visualizer import Visualizer from os.path import join, realpath from os import makedirs, environ from openravepy import matrixFromAxisAngle, Sensor from math import pi import time from copy import copy from numpy import array if __name__ == "__main__": dir_test = join(realpath('.'), 'test') environ['OPENRAVE_DATA'] = str(dir_test) cfg = TurbineConfig.load('turbine_unittest.cfg', 'test') turb = Turbine(cfg) turb.env.Remove(turb.primary) turb.env.Remove(turb.secondary) turb.env.Remove(turb.iris) turb.env.Remove(turb.rotor) turb.env.Remove(turb.runner_area) turb.env.Remove(turb.blades[1]) turb.env.Remove(turb.blades[2]) turb.env.Remove(turb.blades[3]) # Visualizer vis = Visualizer(turb.env) # Move Robot T = array([[-1, 0, 0, 2.21], [0, 0, 1, -3.42], [0, 1, 0, 0.69],
from numpy import pi, array, dot import dynamics import matplotlib.pylab as plt import matplotlib.gridspec as gridspec from turbine import Turbine # Turn off gravity dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = True # Create model bladed_file = r"C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj" tb = Turbine(bladed_file, rigid=False) tb.set_base_motion(4, 0.80, 10 * pi / 180) # t,y = tb.simulate(rotor_speed=2, t1=60, dt=0.05, init=True) def p(parts=False): fig = plt.figure() fig.set_size_inches(15, 10, forward=True) gs = gridspec.GridSpec(6, 2) motion = ["surge", "sway", "heave", "roll", "pitch", "yaw"][tb.base_motion] fig.suptitle("Blade loads in response to base motion: {}".format(motion)) assert motion == "pitch" az = [y[1][:, 0], y[6][:, 0], y[11][:, 0]] pitch = [y[0][:, tb.base_motion], y[5][:, tb.base_motion], y[10][:, tb.base_motion]] mh = tb.modes.mass * tb.tower.hubheight
import dynamics from turbine import Turbine # Turn off gravity dynamics.OPT_GRAVITY = True dynamics.OPT_GEOMETRIC_STIFFNESS = True # Parameters pitch_freq = 0.3 # rad/s pitch_amp = 0.3 # rad rotor_speed = 2 # rad/s # Create model bladed_file = r'C:\Users\Rick Lupton\Dropbox\phd\Bladed\Models\OC3-Hywind_SparBuoy_NREL5MW.prj' tb = Turbine(bladed_file) # Linearise model and simulate lin = tb.lin(az0=0, rotor_speed=rotor_speed, init=True) t, yl = lin.integrate(90) # Convert to MBC and simulate mbclin = lin.multiblade_transform( (0, rotor_speed), [range(0, 4), range(4, 8), range(8, 12)]) t, ym = mbclin.integrate(90) # Simulate original full system #t,y = tb.simulate(rotor_speed=2, t1=90, dt=0.10, init=True)
class CAES: def __init__(self,V=1000.,cmp_eff=80.,trb_eff=90.,p=200000): # Air Side self.amb = Ambient() self.cmp = Compressor(eff=cmp_eff) self.tank = Tank(V=V,p=p) self.trb = Turbine(eff=trb_eff) self.m_dot_i = 0.0 self.m_dot_o = 0.0 # Heat Side # Create pandas DataFrame to store results self.df = pd.DataFrame(columns=variables) def update(self, pwr, dt): # Charge if pwr>0.0: self.charge(pwr, dt) # Discharge elif pwr > 0.0: self.discharge(pwr, dt) # Do nothing else: self.maintain(dt) def charge(self, pwr, dt): # Do something state1 = self.amb.state p_tank = self.tank.state.p state2 = self.cmp.compress(state1, p_tank,pwr) m_dot_i = self.cmp.m_dot state3 = state2 # Hxer - to be added self.tank.charge(state3,m_dot_i,dt) self.m_dot_i = m_dot_i def discharge(self, pwr, dt): state4 = self.tank.state state5 = state4 # Hxer - to be added p_amb = self.amb.state.p state6 = self.trb.expand(state4, p_amb) m_dot = pwr / (state4.h - state5.h) self.tank.discharge(state4, m_dot, dt) def maintain(self, dt): # Turn Everything off def saveState(self, pwr, dt): #----- # Prepare series to store current state #----- s = pd.Series(index=variables) #----- # System Level #----- s['dt'] = dt s['pwr'] = pwr #----- # Fluid #----- # Tanks s['fluid_TA'] = 0.0 s['fluid_TC'] = 0.0 s['fluid_TH'] = 0.0 # Flow paths s['fluid_A'] = self.cmp.m_dot s['fluid_B'] = 0.0 s['fluid_C'] = 0.0 s['fluid_D'] = 0.0 s['fluid_E'] = 0.0 #----- # Mass stored (Tanks only) #----- s['m_TA'] = self.tank.m s['m_TC'] = 0.0 s['m_TH'] = 0.0 #----- # Mass flow rate (Flow paths only) #----- s['m_dot_A'] = self.cmp.m_dot s['m_dot_B'] = 0.0 s['m_dot_C'] = 0.0 s['m_dot_D'] = 0.0 s['m_dot_E'] = 0.0 #----- # Temperature #----- # Tanks s['T_TA'] = 0.0