コード例 #1
0
ファイル: th_component.py プロジェクト: pyrk/pyrk
    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]
コード例 #2
0
ファイル: th_component.py プロジェクト: wuhao1938/pyrk
    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]
コード例 #3
0
    def advance_time(self, time):
        """Advances the timer to a specific time

        :param time: the time to advance to
        :type time: Quantity units seconds
        """
        new_ts = self.t_idx(time)
        old_ts = self.ts
        if (abs(new_ts - old_ts) > 1):
            msg = "At timestep "
            msg += str(self.ts)
            msg += ", which translates to time ("
            msg += str(self.t(self.ts))
            msg += ") the new timestep ("
            msg += str(new_ts)
            msg += ") was more than one step greater than the old timestep: "
            msg += str(old_ts)
            raise RuntimeError(msg)
        self.ts = new_ts
        return validation.validate_le("current time", time, self.tf)
コード例 #4
0
ファイル: test_validation.py プロジェクト: tylerweis14/pyrk
def test_le_both_large():
    val = 1000000000000000
    valname = "testval"
    ulim = val
    assert_equal(v.validate_le(valname, val, ulim), val)
コード例 #5
0
ファイル: test_validation.py プロジェクト: tylerweis14/pyrk
def test_le_right_type():
    val = 1
    valname = "testval"
    ulim = 10
    assert_equal(v.validate_le(valname, val, ulim), val)
コード例 #6
0
ファイル: test_validation.py プロジェクト: joosm/pyrk
def test_le_both_large():
    val = 1000000000000000
    valname = "testval"
    ulim = val
    assert_equal(v.validate_le(valname, val, ulim), val)
コード例 #7
0
ファイル: test_validation.py プロジェクト: joosm/pyrk
def test_le_right_type():
    val = 1
    valname = "testval"
    ulim = 10
    assert_equal(v.validate_le(valname, val, ulim), val)