Ejemplo n.º 1
0
    def __init__(self, name=None,
                 k=0*units.watt/units.meter/units.kelvin,
                 cp=0*units.joule/units.kg/units.kelvin,
                 mu=0*units.pascal*units.seconds,
                 dm=DensityModel()):
        """Initalizes a material

        :param name: The name of the component (i.e., "fuel" or "cool")
        :type name: str.
        :param k: The thermal conductivity of the component
        :type k: float, pint.unit.Quantity :math:'watt/meter/K'
        :param cp: specific heat capacity, :math:`c_p`, in :math:`J/kg-K`
        :type cp: float, pint.unit.Quantity :math:`J/kg-K`
        :param mu: dynamic viscosity(for fluid), :math:`mu`, in :math:`Pa.s`
        :type mu: float, pint.unit.Quantity :math:`Pa.s`
        :param dm: The density of the material
        :type dm: DensityModel object
        """
        self.name = name
        self.k = k.to('watt/meter/kelvin')
        validation.validate_ge("k", k, 0*units.watt/units.meter/units.kelvin)
        self.cp = cp.to('joule/kg/kelvin')
        validation.validate_ge("cp", cp, 0*units.joule/units.kg/units.kelvin)
        self.mu = mu.to('pascal*seconds')
        self.dm = dm
Ejemplo n.º 2
0
 def temp(self, timestep):
     """The temperature of this component at the chosen timestep
     :param timestep: the timestep at which to query the temperature
     :type timestep: int
     :return: the temperature of the component at the chosen timestep
     :rtype: float, in units of kelvin
     """
     validation.validate_ge("timestep", timestep, 0)
     validation.validate_le("timestep", timestep, self.timer.timesteps())
     return self.T[timestep]
Ejemplo n.º 3
0
 def temp(self, timestep):
     """The temperature of this component at the chosen timestep
     :param timestep: the timestep at which to query the temperature
     :type timestep: int
     :return: the temperature of the component at the chosen timestep
     :rtype: float, in units of kelvin
     """
     validation.validate_ge("timestep", timestep, 0)
     validation.validate_le("timestep", timestep, self.timer.timesteps())
     return self.T[timestep]
Ejemplo n.º 4
0
 def __init__(self,
              t0=0.0*units.seconds,
              tf=1.0*units.seconds,
              dt=1.0*units.seconds):
     self.t0 = validation.validate_ge("t0", t0, 0.0*units.seconds)
     self.tf = validation.validate_ge("tf", tf, t0)
     self.dt = validation.validate_ge("dt", dt, 0.0*units.seconds)
     self.series = units.Quantity(np.linspace(start=t0.magnitude,
                                              stop=tf.magnitude,
                                              num=self.timesteps()),
                                  'seconds')
     self.ts = 0
Ejemplo n.º 5
0
 def __init__(self,
              t0=0.0*units.seconds,
              tf=1.0*units.seconds,
              dt=1.0*units.seconds):
     self.t0 = validation.validate_ge("t0", t0, 0.0*units.seconds)
     self.tf = validation.validate_ge("tf", tf, t0)
     self.dt = validation.validate_ge("dt", dt, 0.0*units.seconds)
     self.series = units.Quantity(np.linspace(start=t0.magnitude,
                                              stop=tf.magnitude,
                                              num=self.timesteps()),
                                  'seconds')
     self.ts = 0
Ejemplo n.º 6
0
    def __init__(self,
                 name=None,
                 mat=Material(),
                 vol=0 * units.meter**3,
                 T0=0 * units.kelvin,
                 alpha_temp=0 * units.delta_k / units.kelvin,
                 timer=Timer(),
                 heatgen=False,
                 power_tot=0 * units.watt):
        """Initalizes a thermal hydraulic component.
        A thermal-hydraulic component will be treated as one "lump" in the
        lumped capacitance model.

        :param name: The name of the component (i.e., "fuel" or "cool")
        :type name: str.
        :param vol: The volume of the component
        :type vol: float meter**3
        :param T0: The initial temperature of the component
        :type T0: float.
        :param alpha_temp: temperature coefficient of reactivity
        :type alpha_temp: float
        :param timer: The timer instance for the sim
        :type timer: Timer object
        :param heatgen: is this component a heat generator (fuel)
        :type heatgen: bool
        """
        self.name = name
        self.vol = vol.to('meter**3')
        validation.validate_ge("vol", vol, 0 * units.meter**3)
        self.k = mat.k
        self.cp = mat.cp
        self.dm = mat.dm
        self.T0 = T0.to('kelvin')
        validation.validate_num("T", T0)
        self.T = units.Quantity(
            np.zeros(shape=(timer.timesteps(), ), dtype=float), 'kelvin')
        self.T[0] = T0
        self.alpha_temp = alpha_temp.to('delta_k/kelvin')
        self.timer = timer
        self.heatgen = heatgen
        self.power_tot = power_tot
        self.cond = {}
        self.conv = {}
        self.mass = {}
        self.cust = {}
        self.prev_t_idx = 0
Ejemplo n.º 7
0
    def __init__(self, name=None,
                 mat=Material(),
                 vol=0*units.meter**3,
                 T0=0*units.kelvin,
                 alpha_temp=0*units.delta_k/units.kelvin,
                 timer=Timer(),
                 heatgen=False,
                 power_tot=0*units.watt):
        """Initalizes a thermal hydraulic component.
        A thermal-hydraulic component will be treated as one "lump" in the
        lumped capacitance model.

        :param name: The name of the component (i.e., "fuel" or "cool")
        :type name: str.
        :param vol: The volume of the component
        :type vol: float meter**3
        :param T0: The initial temperature of the component
        :type T0: float.
        :param alpha_temp: temperature coefficient of reactivity
        :type alpha_temp: float
        :param timer: The timer instance for the sim
        :type timer: Timer object
        :param heatgen: is this component a heat generator (fuel)
        :type heatgen: bool
        """
        self.name = name
        self.vol = vol.to('meter**3')
        validation.validate_ge("vol", vol, 0*units.meter**3)
        self.k = mat.k
        self.cp = mat.cp
        self.dm = mat.dm
        self.T0 = T0.to('kelvin')
        validation.validate_num("T", T0)
        self.T = units.Quantity(np.zeros(shape=(timer.timesteps(),),
                                         dtype=float), 'kelvin')
        self.T[0] = T0
        self.alpha_temp = alpha_temp.to('delta_k/kelvin')
        self.timer = timer
        self.heatgen = heatgen
        self.power_tot = power_tot
        self.cond = {}
        self.conv = {}
        self.mass = {}
        self.cust = {}
        self.prev_t_idx = 0
Ejemplo n.º 8
0
    def __init__(self,
                 t0=0.0*units.seconds,
                 tf=1.0*units.seconds,
                 dt=1.0*units.seconds,
                 t_feedback=0.0*units.seconds):
        """Initialize the timer object. There should be only one.

        :param t0: first times in the simulation
        :type t0: float, units of seconds
        :param tf: last time in the simulation
        :type tf: float, units of seconds
        :param dt: size of the timestep
        :type dt: float, units of seconds
        """
        self.t0 = validation.validate_ge("t0", t0, 0.0*units.seconds)
        self.tf = validation.validate_ge("tf", tf, t0)
        self.dt = validation.validate_ge("dt", dt, 0.0*units.seconds)
        self.series = units.Quantity(np.linspace(start=t0.magnitude,
                                                 stop=tf.magnitude,
                                                 num=self.timesteps()),
                                     'seconds')
        self.ts = 0
        self.t_idx_feedback = self.t_idx(t_feedback)
Ejemplo n.º 9
0
    def __init__(self,
                 t0=0.0 * units.seconds,
                 tf=1.0 * units.seconds,
                 dt=1.0 * units.seconds,
                 t_feedback=0.0 * units.seconds):
        """Initialize the timer object. There should be only one.

        :param t0: first times in the simulation
        :type t0: float, units of seconds
        :param tf: last time in the simulation
        :type tf: float, units of seconds
        :param dt: size of the timestep
        :type dt: float, units of seconds
        """
        self.t0 = validation.validate_ge("t0", t0, 0.0 * units.seconds)
        self.t_feedback = validation.validate_ge("t_feedback", t_feedback, t0)
        self.tf = validation.validate_ge("tf", tf, t_feedback)
        self.dt = validation.validate_g("dt", dt, 0.0 * units.seconds)
        self.series = units.Quantity(
            np.linspace(start=t0.magnitude,
                        stop=tf.magnitude,
                        num=self.timesteps()), 'seconds')
        self.ts = 0
        self.t_idx_feedback = self.t_idx(t_feedback)