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]
def __init__(self, name=None, k=0 * units.watt / units.meter / units.kelvin, cp=0 * units.joule / units.kg / units.kelvin, dm=DensityModel(), mu=0 * units.pascal * units.seconds): """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 dm: The density of the material :type dm: DensityModel object :param mu: dynamic viscosity(for fluid), :math:`mu`, in :math:`Pa.s` :type mu: float, pint.unit.Quantity :math:`Pa.s` """ Material.__init__(self, name, k, cp, dm) self.mu = mu.to('pascal*seconds') validation.validate_ge("mu", mu, 0 * units.pascal * units.seconds)
def __init__(self, name=None, k=0 * units.watt / units.meter / units.kelvin, cp=0 * units.joule / units.kg / units.kelvin, 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 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.dm = dm
def __init__(self, name=None, k=0 * units.watt / units.meter / units.kelvin, cp=0 * units.joule / units.kg / units.kelvin, 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 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.dm = dm
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)
def test_ge_both_neg(): val = -2 valname = "testval" llim = -3 assert_equal(v.validate_ge(valname, val, llim), val)
def test_ge_right_type(): val = 10 valname = "testval" llim = 0 assert_equal(v.validate_ge(valname, val, llim), val)
def test_ge_Quantity_type(): val = 10 * units.meter valname = "testval" llim = 0 * units.meter assert_equal(v.validate_ge(valname, val, llim), val)
def test_ge_Quantity_type(): val = 10*units.meter valname = "testval" llim = 0*units.meter assert_equal(v.validate_ge(valname, val, llim), val)