Exemplo n.º 1
0
    def test_step_turn_on_forbidden(self):
        ''' the cu musn't be paused (self_offtime active)'''
        #initialize with valid parameters
        self.cu.running = True

        # the offtime is effective!
        now = self.env.now
        self.cu.off_time = now + 1

        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        self.heat_storage.get_required_energy.return_value=1000

        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        self.assertEqual(self.cu._workload, 0, "wrong workload " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.total_electrical_production, 0,
            "wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(self.cu.total_gas_consumption, 0,
            "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(self.cu.total_thermal_production, 0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(self.power_meter.energy_produced, 0,
            "energy_produced(power_meter) " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.heat_storage.add_energy.assert_called_with(0)
Exemplo n.º 2
0
    def test_too_low_workload(self):
        ''' The workload should be zero if the given workload is
        less than the minimal workload.'''
        precalculated_workload = 0.10
        old_hours = self.total_hours_of_operation

        self.cu.set_workload(precalculated_workload)

        self.assertEqual(
            self.cu._workload, 0,
            "workload is wrong. " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.current_gas_consumption, 0,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption, 0))
        self.assertEqual(
            self.cu.current_electrical_production, 0,
            "current_electrical_production is wrong. " +
            values_comparison(self.cu.current_electrical_production, 0))
        self.assertEqual(
            self.cu.current_thermal_production, 0,
            "current_thermal_production is wrong. " +
            values_comparison(self.cu.current_thermal_production, 0))
        self.assertEqual(
            self.cu.total_hours_of_operation, old_hours,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation, old_hours))
Exemplo n.º 3
0
    def test_workload_off_time_effective(self):
        '''If the offtime is in the future the bhkw must stay turned off.'''
        self.cu.off_time = self.env.now + 1
        old_hours = self.total_hours_of_operation

        self.cu.set_workload(self.cu.calculate_new_workload())

        self.assertEqual(
            self.cu._workload, 0,
            "workload is wrong. " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.current_gas_consumption, 0,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption, 0))
        self.assertEqual(
            self.cu.current_electrical_production, 0,
            "current_electrical_production is wrong." +
            values_comparison(self.cu.current_electrical_production, 0))
        self.assertEqual(
            self.cu.current_thermal_production, 0,
            "current_thermal_production is wrong . " +
            values_comparison(self.cu.current_thermal_production, 0))
        self.assertEqual(
            self.cu.total_hours_of_operation, old_hours,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation, old_hours))
Exemplo n.º 4
0
    def test_step_turn_target_temperature_reached(self):
        '''if the heat storage is too hot, the cu musn't produce energy
            although there is a demand for electrical energy'''
        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 10.0
        self.heat_storage.target_temperature = 10.0

        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        self.assertEqual(self.cu._workload, 0, "wrong workload " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.total_electrical_production, 0,
            "wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(self.cu.total_gas_consumption, 0,
            "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(self.cu.total_thermal_production, 0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(self.power_meter.energy_produced, 0,
            "energy_produced(power_meter) " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.heat_storage.add_energy.assert_called_with(0)
Exemplo n.º 5
0
    def test_step_turn_target_temperature_reached(self):
        '''if the heat storage is too hot, the cu musn't produce energy
            although there is a demand for electrical energy'''
        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 10.0
        self.heat_storage.target_temperature = 10.0

        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        self.assertEqual(
            self.cu._workload, 0,
            "wrong workload " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.total_electrical_production, 0,
            "wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(
            self.cu.total_gas_consumption, 0, "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(
            self.cu.total_thermal_production, 0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(
            self.power_meter.energy_produced, 0,
            "energy_produced(power_meter) " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.heat_storage.add_energy.assert_called_with(0)
Exemplo n.º 6
0
    def test_step_electric(self):
        #if the mode is electric the cu will produce energy
        #according to the electric demand

        self.cu.thermal_driven = False

        self.heat_storage.temperature = 0.0
        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        expected_workload = self.calculate_workload(required_energy,
                                                    self.electrical_efficiency)

        new_gas_consumption = self.calculate_gas_consumption(expected_workload)
        self.total_gas_consumption += new_gas_consumption

        new_electrical_energy = self.calculate_energy(
            expected_workload, self.electrical_efficiency)
        self.total_electrical_production += new_electrical_energy

        new_thermal_energy = self.calculate_energy(expected_workload,
                                                   self.thermal_efficiency)
        self.total_thermal_production += new_thermal_energy

        expected_energy_produced = self.cu.get_electrical_energy_production()
        expected_input_energy = self.cu.get_thermal_energy_production()
        self.assertAlmostEqual(
            self.cu._workload,
            expected_workload,
            msg="wrong workload " +
            values_comparison(self.cu._workload, expected_workload))
        self.assertAlmostEqual(
            self.cu.total_electrical_production,
            self.total_electrical_production,
            msg="wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production,
                              self.total_electrical_production))
        self.assertAlmostEqual(
            self.cu.total_gas_consumption,
            self.total_gas_consumption,
            msg="wrong total_gas_consumption " + values_comparison(
                self.cu.total_gas_consumption, self.total_gas_consumption))
        self.assertAlmostEqual(
            self.cu.total_thermal_production,
            self.total_thermal_production,
            msg="wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production,
                              self.total_thermal_production))
        self.assertAlmostEqual(
            self.power_meter.energy_produced,
            expected_energy_produced,
            msg="wrong energy_produced(power_meter)" + values_comparison(
                self.power_meter.energy_produced, expected_energy_produced))
        self.heat_storage.add_energy.assert_called_with(expected_input_energy)
Exemplo n.º 7
0
    def test_step_electric(self):
        #if the mode is electric the cu will produce energy
        #according to the electric demand

        self.cu.thermal_driven = False

        self.heat_storage.temperature = 0.0
        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        expected_workload = self.calculate_workload(required_energy,
                                self.electrical_efficiency)

        new_gas_consumption = self.calculate_gas_consumption(expected_workload)
        self.total_gas_consumption += new_gas_consumption

        new_electrical_energy = self.calculate_energy(expected_workload,
                                    self.electrical_efficiency)
        self.total_electrical_production += new_electrical_energy

        new_thermal_energy = self.calculate_energy(expected_workload,
                                    self.thermal_efficiency)
        self.total_thermal_production += new_thermal_energy

        expected_energy_produced = self.cu.get_electrical_energy_production()
        expected_input_energy = self.cu.get_thermal_energy_production()
        self.assertAlmostEqual(self.cu._workload, expected_workload,
            msg="wrong workload " +
            values_comparison(self.cu._workload, expected_workload))
        self.assertAlmostEqual(self.cu.total_electrical_production,
            self.total_electrical_production,
            msg="wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production,
            self.total_electrical_production))
        self.assertAlmostEqual(self.cu.total_gas_consumption,
            self.total_gas_consumption,
            msg="wrong total_gas_consumption " +
            values_comparison(self.cu.total_gas_consumption,
            self.total_gas_consumption))
        self.assertAlmostEqual(self.cu.total_thermal_production,
            self.total_thermal_production,
            msg="wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production,
            self.total_thermal_production))
        self.assertAlmostEqual(self.power_meter.energy_produced,
            expected_energy_produced,
            msg="wrong energy_produced(power_meter)" +
            values_comparison(self.power_meter.energy_produced,
            expected_energy_produced))
        self.heat_storage.add_energy.assert_called_with(expected_input_energy)
Exemplo n.º 8
0
    def test_step_workload_too_high(self):
        '''if the workload is too high, the cu will be running at a workload
        of 100 %'''

        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        self.heat_storage.get_required_energy.return_value = 1000

        required_energy = 500.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        expected_workload = 1
        new_gas_consumption = self.calculate_gas_consumption(expected_workload)
        self.total_gas_consumption += new_gas_consumption

        new_electrical_energy = self.calculate_energy(
            expected_workload, self.electrical_efficiency)
        self.total_electrical_production += new_electrical_energy

        new_thermal_energy = self.calculate_energy(expected_workload,
                                                   self.thermal_efficiency)
        self.total_thermal_production += new_thermal_energy

        self.assertEqual(
            self.cu._workload, expected_workload, "wrong workload" +
            values_comparison(self.cu._workload, expected_workload))
        self.assertEqual(
            self.cu.total_electrical_production,
            self.total_electrical_production,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production,
                              self.total_electrical_production))
        self.assertAlmostEqual(
            self.cu.total_gas_consumption, self.total_gas_consumption,
            "total_gas_consumption " + values_comparison(
                self.cu.total_gas_consumption, self.total_gas_consumption))
        self.assertAlmostEqual(
            self.cu.total_thermal_production, self.total_thermal_production,
            "wrong total_thermal_production" +
            values_comparison(self.cu.total_thermal_production,
                              self.total_thermal_production))
        self.assertEqual(
            self.power_meter.energy_produced, new_electrical_energy,
            "wrong energy_produced (power_meter)" + values_comparison(
                self.power_meter.energy_produced, new_electrical_energy))
        self.heat_storage.add_energy.assert_called_with(new_thermal_energy)
Exemplo n.º 9
0
    def test_step_workload_too_high(self):
        '''if the workload is too high, the cu will be running at a workload
        of 100 %'''

        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        self.heat_storage.get_required_energy.return_value=1000

        required_energy = 500.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        expected_workload = 1
        new_gas_consumption = self.calculate_gas_consumption(expected_workload)
        self.total_gas_consumption += new_gas_consumption

        new_electrical_energy = self.calculate_energy(expected_workload,
                                    self.electrical_efficiency)
        self.total_electrical_production += new_electrical_energy

        new_thermal_energy = self.calculate_energy(expected_workload,
                                    self.thermal_efficiency)
        self.total_thermal_production += new_thermal_energy

        self.assertEqual(self.cu._workload, expected_workload,
            "wrong workload" +
            values_comparison(self.cu._workload, expected_workload))
        self.assertEqual(self.cu.total_electrical_production,
            self.total_electrical_production,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production,
            self.total_electrical_production))
        self.assertAlmostEqual(self.cu.total_gas_consumption,
            self.total_gas_consumption,
            "total_gas_consumption " + values_comparison(
                self.cu.total_gas_consumption, self.total_gas_consumption))
        self.assertAlmostEqual(self.cu.total_thermal_production,
            self.total_thermal_production, "wrong total_thermal_production" +
                values_comparison(self.cu.total_thermal_production,
                self.total_thermal_production))
        self.assertEqual(self.power_meter.energy_produced,
            new_electrical_energy, "wrong energy_produced (power_meter)" +
            values_comparison(self.power_meter.energy_produced,
            new_electrical_energy))
        self.heat_storage.add_energy.assert_called_with(new_thermal_energy)
Exemplo n.º 10
0
    def test_normal_workload(self):
        '''The given workload shouldn't be altered if the workload is valid.
            current gas consumption,
            current electrical production,
            current thermal production and
            total_hours_of_operation
            should be set.
        '''
        precalculated_workload = 0.5

        self.cu.set_workload(precalculated_workload)
        self.cu.consume_and_produce_energy()

        expected_current_gas_consumption = self.gas_input * \
            precalculated_workload

        complete_current_power = expected_current_gas_consumption * \
            self.cu.get_efficiency_loss_factor()

        expected_current_electrical_production = self.electrical_efficiency * \
            complete_current_power
        expected_current_thermal_production = self.thermal_efficiency * \
            complete_current_power

        # assumption: self.env.step_size are seconds per step
        self.total_hours_of_operation += self.env.step_size / (60.0 * 60.0)

        self.assertEqual(
            self.cu._workload, precalculated_workload,
            "new workload is wrong. " +
            values_comparison(self.cu._workload, precalculated_workload))
        self.assertEqual(
            self.cu.current_gas_consumption, expected_current_gas_consumption,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption,
                              expected_current_gas_consumption))
        self.assertAlmostEqual(self.cu.current_electrical_production,
                               expected_current_electrical_production)
        self.assertAlmostEqual(self.cu.current_thermal_production,
                               expected_current_thermal_production)
        self.assertEqual(
            self.cu.total_hours_of_operation, self.total_hours_of_operation,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation,
                              self.total_hours_of_operation))
Exemplo n.º 11
0
    def test_normal_workload(self):
        '''The given workload shouldn't be altered if the workload is valid.
            current gas consumption,
            current electrical production,
            current thermal production and
            total_hours_of_operation
            should be set.
        '''
        precalculated_workload = 0.5

        self.cu.set_workload(precalculated_workload)
        self.cu.consume_and_produce_energy()

        expected_current_gas_consumption = self.gas_input * \
            precalculated_workload

        complete_current_power = expected_current_gas_consumption * \
            self.cu.get_efficiency_loss_factor()

        expected_current_electrical_production = self.electrical_efficiency * \
            complete_current_power
        expected_current_thermal_production = self.thermal_efficiency * \
            complete_current_power

        # assumption: self.env.step_size are seconds per step
        self.total_hours_of_operation += self.env.step_size/(60.0*60.0)

        self.assertEqual(self.cu._workload, precalculated_workload,
            "new workload is wrong. " +
            values_comparison(self.cu._workload, precalculated_workload))
        self.assertEqual(self.cu.current_gas_consumption,
            expected_current_gas_consumption,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption,
                expected_current_gas_consumption))
        self.assertAlmostEqual(self.cu.current_electrical_production,
            expected_current_electrical_production)
        self.assertAlmostEqual(self.cu.current_thermal_production,
            expected_current_thermal_production)
        self.assertEqual(self.cu.total_hours_of_operation,
            self.total_hours_of_operation,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation,
                self.total_hours_of_operation))
Exemplo n.º 12
0
    def test_too_high_workload(self):
        '''If the workload is greater than 1 it should be truncated to 1.'''
        precalculated_workload = 2.0

        self.cu.set_workload(precalculated_workload)
        self.cu.consume_and_produce_energy()

        expected_current_gas_consumption = self.gas_input

        complete_current_power = expected_current_gas_consumption * \
            self.cu.get_efficiency_loss_factor()

        expected_current_electrical_production = self.electrical_efficiency * \
            complete_current_power
        expected_current_thermal_production = self.thermal_efficiency * \
            complete_current_power
        # assumption: self.env.step_size are seconds per step
        self.total_hours_of_operation += self.env.step_size / (60.0 * 60.0)

        self.assertEqual(
            self.cu._workload, 1,
            "wrong workload. " + values_comparison(self.cu._workload, 1))
        self.assertEqual(
            self.cu.current_gas_consumption, expected_current_gas_consumption,
            "wrong current_gas_consumption. " +
            values_comparison(self.cu.current_gas_consumption,
                              expected_current_gas_consumption))
        self.assertEqual(
            self.cu.current_electrical_production,
            expected_current_electrical_production,
            "wrong expected_current_electrical_production. " +
            values_comparison(self.cu.current_electrical_production,
                              expected_current_electrical_production))
        self.assertEqual(
            self.cu.current_thermal_production,
            expected_current_thermal_production,
            "wrong current_thermal_production. " +
            values_comparison(self.cu.current_thermal_production,
                              expected_current_thermal_production))
        self.assertEqual(
            self.cu.total_hours_of_operation, self.total_hours_of_operation,
            "wrong total_hours_of_operation. " +
            values_comparison(self.cu.total_hours_of_operation,
                              self.total_hours_of_operation))
Exemplo n.º 13
0
    def test_too_high_workload(self):
        '''If the workload is greater than 1 it should be truncated to 1.'''
        precalculated_workload = 2.0

        self.cu.set_workload(precalculated_workload)
        self.cu.consume_and_produce_energy()

        expected_current_gas_consumption = self.gas_input

        complete_current_power = expected_current_gas_consumption * \
            self.cu.get_efficiency_loss_factor()

        expected_current_electrical_production = self.electrical_efficiency * \
            complete_current_power
        expected_current_thermal_production = self.thermal_efficiency * \
            complete_current_power
        # assumption: self.env.step_size are seconds per step
        self.total_hours_of_operation += self.env.step_size/(60.0*60.0)

        self.assertEqual(self.cu._workload, 1,
            "wrong workload. " +
            values_comparison(self.cu._workload, 1))
        self.assertEqual(self.cu.current_gas_consumption,
            expected_current_gas_consumption,
            "wrong current_gas_consumption. " +
            values_comparison(self.cu.current_gas_consumption,
            expected_current_gas_consumption))
        self.assertEqual(self.cu.current_electrical_production,
            expected_current_electrical_production,
            "wrong expected_current_electrical_production. " +
            values_comparison(self.cu.current_electrical_production,
            expected_current_electrical_production))
        self.assertEqual(self.cu.current_thermal_production,
            expected_current_thermal_production,
            "wrong current_thermal_production. " +
            values_comparison(self.cu.current_thermal_production,
            expected_current_thermal_production))
        self.assertEqual(self.cu.total_hours_of_operation,
            self.total_hours_of_operation,
            "wrong total_hours_of_operation. " +
            values_comparison(self.cu.total_hours_of_operation,
            self.total_hours_of_operation))
Exemplo n.º 14
0
    def test_consume_and_produce_energy(self):
        '''increases total_gas_consumtion,
        total_thermal_production and
        total_electrical_production
        all are measured in energy'''
        self.cu.total_gas_consumption = 0
        self.cu.total_thermal_production = 0
        self.cu.total_electrical_production = 0
        self.cu._workload = 1

        self.cu.consume_and_produce_energy()

        self.assertGreater(self.cu.total_gas_consumption,0,
            "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption,0))
        self.assertGreater(self.cu.total_thermal_production,0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production,0))
        self.assertGreater(self.cu.total_electrical_production,0,
            "wrong total_electrical_production" +
            values_comparison(self.cu.total_electrical_production,0))
Exemplo n.º 15
0
    def test_step_running_thermal_too_little_workload(self):
        '''if the workload is too low, the cu will be turned off
        and the effective workload is zero'''
        self.cu.thermal_driven = True

        self.heat_storage.get_required_energy.return_value = 0.1
        self.power_meter.energy_produced = 0.0 #ToDo

        self.cu.step()

        # caluclates_workload
        # = required_energy/max_gas_amount_input*thermal_efficiency
        # 0.1/(19*0.65) < 40 (minimal workload)

        self.assertEqual(self.cu._workload, 0, "wrong workload. " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.total_electrical_production, 0,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(self.cu.total_gas_consumption, 0,
            "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(self.cu.total_thermal_production, 0,
            "wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(self.power_meter.energy_produced, 0,
            "wrong energy_produced (power_meter). " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.assertEqual(self.heat_storage.input_energy, 0,
            "wrong input_energy (heat_storage). " +
            values_comparison(self.heat_storage.input_energy, 0))
Exemplo n.º 16
0
    def test_step_not_running(self):
        self.cu._workload = 1
        self.cu.running = False
        self.cu.thermal_driven = True
        self.heat_storage.required_energy = 20

        self.heat_storage.get_required_energy.return_value = 20
        self.heat_storage.temperature = 0.0
        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 0.0
        self.heat_storage.input_energy = 0

        self.cu.step()

        self.assertEqual(self.cu._workload, 0, "wrong workload. " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.total_electrical_production, 0,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(self.cu.total_gas_consumption, 0,
            "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(self.cu.total_thermal_production, 0,
            "wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(self.power_meter.energy_produced, 0,
            "wrong energy_produced (power_meter). " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.assertEqual(self.heat_storage.input_energy, 0,
            "wrong input_energy (heat_storage). " +
            values_comparison(self.heat_storage.input_energy, 0))
Exemplo n.º 17
0
    def test_workload_off_time_effective(self):
        '''If the offtime is in the future the bhkw must stay turned off.'''
        self.cu.off_time = self.env.now + 1
        old_hours = self.total_hours_of_operation

        self.cu.set_workload(self.cu.calculate_new_workload())

        self.assertEqual(self.cu._workload, 0,
            "workload is wrong. " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.current_gas_consumption, 0,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption, 0))
        self.assertEqual(self.cu.current_electrical_production, 0,
            "current_electrical_production is wrong." +
            values_comparison(self.cu.current_electrical_production, 0))
        self.assertEqual(self.cu.current_thermal_production, 0,
            "current_thermal_production is wrong . " +
            values_comparison(self.cu.current_thermal_production, 0))
        self.assertEqual(self.cu.total_hours_of_operation, old_hours,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation, old_hours))
Exemplo n.º 18
0
    def test_step_turn_on_forbidden(self):
        ''' the cu musn't be paused (self_offtime active)'''
        #initialize with valid parameters
        self.cu.running = True

        # the offtime is effective!
        now = self.env.now
        self.cu.off_time = now + 1

        self.cu.thermal_driven = False

        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 90.0
        self.heat_storage.get_required_energy.return_value = 1000

        required_energy = 2.0
        self.power_meter.current_power_consum = required_energy

        self.cu.step()

        self.assertEqual(
            self.cu._workload, 0,
            "wrong workload " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.total_electrical_production, 0,
            "wrong total_electrical_production " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(
            self.cu.total_gas_consumption, 0, "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(
            self.cu.total_thermal_production, 0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(
            self.power_meter.energy_produced, 0,
            "energy_produced(power_meter) " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.heat_storage.add_energy.assert_called_with(0)
Exemplo n.º 19
0
    def test_consume_and_produce_energy(self):
        '''increases total_gas_consumtion,
        total_thermal_production and
        total_electrical_production
        all are measured in energy'''
        self.cu.total_gas_consumption = 0
        self.cu.total_thermal_production = 0
        self.cu.total_electrical_production = 0
        self.cu._workload = 1

        self.cu.consume_and_produce_energy()

        self.assertGreater(
            self.cu.total_gas_consumption, 0, "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertGreater(
            self.cu.total_thermal_production, 0,
            "wrong total_thermal_production " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertGreater(
            self.cu.total_electrical_production, 0,
            "wrong total_electrical_production" +
            values_comparison(self.cu.total_electrical_production, 0))
Exemplo n.º 20
0
    def test_too_low_workload(self):
        ''' The workload should be zero if the given workload is
        less than the minimal workload.'''
        precalculated_workload = 0.10
        old_hours = self.total_hours_of_operation

        self.cu.set_workload(precalculated_workload)

        self.assertEqual(self.cu._workload, 0,
            "workload is wrong. " +
            values_comparison(self.cu._workload, 0))
        self.assertEqual(self.cu.current_gas_consumption, 0,
            "current_gas_consumption is wrong. " +
            values_comparison(self.cu.current_gas_consumption, 0))
        self.assertEqual(self.cu.current_electrical_production, 0,
            "current_electrical_production is wrong. " +
            values_comparison(self.cu.current_electrical_production, 0))
        self.assertEqual(self.cu.current_thermal_production, 0,
            "current_thermal_production is wrong. " +
            values_comparison(self.cu.current_thermal_production, 0))
        self.assertEqual(self.cu.total_hours_of_operation, old_hours,
            "total_hours_of_operation is wrong. " +
            values_comparison(self.cu.total_hours_of_operation, old_hours))
Exemplo n.º 21
0
    def test_step_not_running(self):
        self.cu._workload = 1
        self.cu.running = False
        self.cu.thermal_driven = True
        self.heat_storage.required_energy = 20

        self.heat_storage.get_required_energy.return_value = 20
        self.heat_storage.temperature = 0.0
        self.heat_storage.get_temperature.return_value = 0.0
        self.heat_storage.target_temperature = 0.0
        self.heat_storage.input_energy = 0

        self.cu.step()

        self.assertEqual(
            self.cu._workload, 0,
            "wrong workload. " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.total_electrical_production, 0,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(
            self.cu.total_gas_consumption, 0, "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(
            self.cu.total_thermal_production, 0,
            "wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(
            self.power_meter.energy_produced, 0,
            "wrong energy_produced (power_meter). " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.assertEqual(
            self.heat_storage.input_energy, 0,
            "wrong input_energy (heat_storage). " +
            values_comparison(self.heat_storage.input_energy, 0))
Exemplo n.º 22
0
    def test_step_running_thermal_too_little_workload(self):
        '''if the workload is too low, the cu will be turned off
        and the effective workload is zero'''
        self.cu.thermal_driven = True

        self.heat_storage.get_required_energy.return_value = 0.1
        self.power_meter.energy_produced = 0.0  #ToDo

        self.cu.step()

        # caluclates_workload
        # = required_energy/max_gas_amount_input*thermal_efficiency
        # 0.1/(19*0.65) < 40 (minimal workload)

        self.assertEqual(
            self.cu._workload, 0,
            "wrong workload. " + values_comparison(self.cu._workload, 0))
        self.assertEqual(
            self.cu.total_electrical_production, 0,
            "wrong total_electrical_production. " +
            values_comparison(self.cu.total_electrical_production, 0))
        self.assertEqual(
            self.cu.total_gas_consumption, 0, "wrong total_gas_consumption. " +
            values_comparison(self.cu.total_gas_consumption, 0))
        self.assertEqual(
            self.cu.total_thermal_production, 0,
            "wrong total_thermal_production. " +
            values_comparison(self.cu.total_thermal_production, 0))
        self.assertEqual(
            self.power_meter.energy_produced, 0,
            "wrong energy_produced (power_meter). " +
            values_comparison(self.power_meter.energy_produced, 0))
        self.assertEqual(
            self.heat_storage.input_energy, 0,
            "wrong input_energy (heat_storage). " +
            values_comparison(self.heat_storage.input_energy, 0))