Пример #1
0
    def calculate(self, time, delta_time):
        self._time_series.set_time(time)
        unit_delta_time = delta_time

        if self._time_converter == None:
            volume = units.to_si(units(self._time_series.volume,
                                       units.litre)) * delta_time
        else:
            volume = units.to_si(
                units(self._time_series.volume,
                      units.litre)) * delta_time / units.value(
                          self._time_converter(1), units.second)

        # thermal losses when used [W/K]
        on_losses = units.value(volume) * units.value(
            Water().weight) * units.value(
                Water().thermal_capacity) / unit_delta_time

        # total thermal losses [W/K]
        losses = self._off_losses + on_losses

        self._temperature = self._temperature + \
                            ((unit_delta_time * losses / self._cb) * (self._temperature_in - self._temperature)) + \
                            (unit_delta_time / self._cb) * self.power
Пример #2
0
    def calculate(self, time, delta_time):

        self._time_series.set_time(time)

        unit_delta_time = delta_time

        volume = units.to_si(units(self._time_series.volume, units.litre))*delta_time/units.value(self._time_converter(1), units.second)

        # thermal losses when used [W/K]
        on_losses = units.value(volume)*units.value(Water().weight)*units.value(Water().thermal_capacity)/unit_delta_time

        # total thermal losses [W/K]
        losses = self._off_losses + on_losses

        self._temperature = self._temperature + \
            ((unit_delta_time*losses/self._cb)*(self._temperature_in-self._temperature)) +\
            (unit_delta_time/self._cb)*self.power
Пример #3
0
 def decode_unit(self, data):
     return units(data)
Пример #4
0
 def isvalid_unit(self, data):
     try:
         units(data)
         return True
     except:
         return False
Пример #5
0
from gridsim.iodata.input import CSVReader
from gridsim.iodata.output import FigureSaver, CSVSaver

# Gridsim simulator.
sim = Simulator()

# Create a simple thermal process: A room thermal coupling between the room and
# the outside temperature.
#    ___________
#   |           |
#   |   room    |
#   |    20 C   |            outside <= example time series (CSV) file
#   |           |]- 3 W/K
#   |___________|
#
celsius = units(20, units.degC)
room = sim.thermal.add(
    ThermalProcess.room('room',
                        50 * units.meter * units.meter, 2.5 * units.metre,
                        units.convert(celsius, units.kelvin)))
outside = sim.thermal.add(
    TimeSeriesThermalProcess('outside',
                             SortedConstantStepTimeSeriesObject(
                                 CSVReader('./data/example_time_series.csv')),
                             lambda t: t * units.hours,
                             temperature_calculator=lambda t: units.convert(
                                 units(t, units.degC), units.kelvin)))

sim.thermal.add(
    ThermalCoupling('room to outside', 1 * units.thermal_conductivity, room,
                    outside))
Пример #6
0
from gridsim.recorder import PlotRecorder
from gridsim.iodata.output import FigureSaver, CSVSaver

# Gridsim simulator.
sim = Simulator()

# Create a simple thermal process: Two rooms and the thermal coupling between
# them and to the outside temperature.
#             __________                        ___________
#           |          |   ________________   |           |
#           |   room1  |]-| room1 to room2 |-[| cold_room |
#           |    18 C  |  |_____50_W/K_____|  |    25 C   |      outside 5 C
#  10 W/K -[|          |                      |           |]- 10 W/K
#           |__________|                      |___________|
#
celsius = units(18, units.degC)
room1 = sim.thermal.add(
    ThermalProcess.room('room1',
                        50 * units.meter * units.meter, 2.5 * units.metre,
                        units.convert(celsius, units.kelvin)))
celsius = units(25, units.degC)
room2 = sim.thermal.add(
    ThermalProcess.room('room2',
                        50 * units.meter * units.meter, 2.5 * units.metre,
                        units.convert(celsius, units.kelvin)))

celsius = units(5, units.degC)
outside = sim.thermal.add(
    ConstantTemperatureProcess('outside', units.convert(celsius,
                                                        units.kelvin)))
Пример #7
0
        pass

    def calculate(self, time, delta_time):
        pass

    def update(self, time, delta_time):
        for el in self._elements:
            el.update(time, delta_time)

Simulator.register_simulation_module(MyModule)


# Create a simulator, add an element and record the temperature signal using
# a recorder.
sim = Simulator()

print("Loading data...")

obj = sim.my.add(MyObject("myObject", CSVReader('./data/example_time_series.csv')))
obj.convert("temperature", lambda t: units(t, units.degC))

rec = PlotRecorder('temperature', units.month, units.kelvin)
sim.record(rec, obj)

print("Running simulation...")

sim.run(units.year, units.day)

print("Saving data...")

FigureSaver(rec, "Temperature").save('./output/timeseries2-example.png')
Пример #8
0
        print '    ' + subject + '.' + self.attribute_name +\
              ' = ' + str(units.convert(value*units.kelvin, self._y_unit))

# Create simulator.
sim = Simulator()

# Setup topology (For simplicity we just take a trivial thermal simulation):
#           __________                             ___________
#          |          |       ___________         |           |
#          | hot_room |]-----| coupling  |-------[| cold_room |
#          |   60 C   |      |   1m2     |        |           |
#          |          |      |__100_W/K__|        |    20 C   |
#          |__________|      <----------->        |___________|
#                                 1m

celsius = units(60, units.degC)
hot_room = sim.thermal.add(ThermalProcess.room('hot_room',
                                               50*units.meter*units.meter,
                                               2.5*units.metre,
                                               celsius.to(units.kelvin)))

celsius = units(20, units.degC)
cold_room = sim.thermal.add(ThermalProcess.room('cold_room',
                                                50*units.meter*units.meter,
                                                2.5*units.metre,
                                                celsius.to(units.kelvin)))

sim.thermal.add(ThermalCoupling('coupling',
                                100*units.thermal_conductivity,
                                hot_room, cold_room))
Пример #9
0
    def calculate(self, time, delta_time):
        pass

    def update(self, time, delta_time):
        for el in self._elements:
            el.update(time, delta_time)


Simulator.register_simulation_module(MyModule)

# Create a simulator, add an element and record the temperature signal using
# a recorder.
sim = Simulator()

print("Loading data...")

obj = sim.my.add(
    MyObject("myObject", CSVReader('./data/example_time_series.csv')))
obj.convert("temperature", lambda t: units(t, units.degC))

rec = PlotRecorder('temperature', units.month, units.kelvin)
sim.record(rec, obj)

print("Running simulation...")

sim.run(units.year, units.day)

print("Saving data...")

FigureSaver(rec, "Temperature").save('./output/timeseries2-example.png')
Пример #10
0
from gridsim.thermal.core import ThermalProcess, ThermalCoupling
from gridsim.iodata.output import CSVSaver

# Create a simulation.
sim = Simulator()

# Setup topology (For simplicity we just take a trivial thermal simulation):
#           __________                             ___________
#          |          |       ___________         |           |
#          | hot_room |]-----| coupling  |-------[| cold_room |
#          |          |      |    1m2    |        |           |
#          |   60 C   |      |__100_W/K__|        |    20 C   |
#          |__________|      <----------->        |___________|
#                                 1m
#
celsius = units(60, units.degC)
hot_room = sim.thermal.add(
    ThermalProcess.room('hot_room', 50 * units.meter * units.meter,
                        2.5 * units.metre, celsius.to(units.kelvin)))

celsius = units(20, units.degC)
cold_room = sim.thermal.add(
    ThermalProcess.room('cold_room', 50 * units.meter * units.meter,
                        2.5 * units.metre, celsius.to(units.kelvin)))

sim.thermal.add(
    ThermalCoupling('coupling', 100 * units.thermal_conductivity, hot_room,
                    cold_room))

# Add the temperature recorder.
temperature_recorder = PlotRecorder('temperature', units.second, units.degC)
Пример #11
0
from gridsim.iodata.input import CSVReader
from gridsim.iodata.output import FigureSaver, CSVSaver

# Gridsim simulator.
sim = Simulator()

# Create a simple thermal process: A room thermal coupling between the room and
# the outside temperature.
#    ___________
#   |           |
#   |   room    |
#   |    20 C   |            outside <= example time series (CSV) file
#   |           |]- 3 W/K
#   |___________|
#
celsius = units(20, units.degC)
room = sim.thermal.add(ThermalProcess.room('room',
                                           50*units.meter*units.meter,
                                           2.5*units.metre,
                                           units.convert(celsius, units.kelvin)))
outside = sim.thermal.add(
    TimeSeriesThermalProcess('outside', SortedConstantStepTimeSeriesObject(CSVReader('./data/example_time_series.csv')),
                             lambda t: t*units.hours,
                             temperature_calculator=
                                lambda t: units.convert(units(t, units.degC), units.kelvin)))

sim.thermal.add(ThermalCoupling('room to outside', 1*units.thermal_conductivity,
                                room, outside))

# Create a plot recorder that records the temperatures of all thermal processes.
temp = PlotRecorder('temperature', units.second, units.degC)
Пример #12
0
# Gridsim simulator.
sim = Simulator()
sim.electrical.load_flow_calculator = DirectLoadFlowCalculator()

# Create a simple thermal process: A room and a thermal coupling between the
# room and the outside temperature.
#    ___________
#   |           |
#   |   room    |
#   |    20 C   |            outside <= example time series (CSV) file
#   |           |]- 3 W/K
#   |___________|
#
# The room has a surface of 50m2 and a height of 2.5m.
celsius = units(20, units.degC)
room = sim.thermal.add(ThermalProcess.room('room',
                                           50*units.meter*units.meter,
                                           2.5*units.metre,
                                           units.convert(celsius, units.kelvin)))

outside = sim.thermal.add(
    TimeSeriesThermalProcess('outside', SortedConstantStepTimeSeriesObject(CSVReader('./data/example_time_series.csv')),
                             lambda t: t*units.hour,
                             temperature_calculator=
                                lambda t: units.convert(units(t, units.degC),
                                                        units.kelvin)))
sim.thermal.add(ThermalCoupling('room to outside',
                                10.0*units.thermal_conductivity,
                                room, outside))
Пример #13
0
from gridsim.recorder import PlotRecorder
from gridsim.iodata.output import FigureSaver, CSVSaver

# Gridsim simulator.
sim = Simulator()

# Create a simple thermal process: Two rooms and the thermal coupling between
# them and to the outside temperature.
#             __________                        ___________
#           |          |   ________________   |           |
#           |   room1  |]-| room1 to room2 |-[| cold_room |
#           |    18 C  |  |_____50_W/K_____|  |    25 C   |      outside 5 C
#  10 W/K -[|          |                      |           |]- 10 W/K
#           |__________|                      |___________|
#
celsius = units(18, units.degC)
room1 = sim.thermal.add(ThermalProcess.room('room1',
                                            50*units.meter*units.meter,
                                            2.5*units.metre,
                                            units.convert(celsius, units.kelvin)))
celsius = units(25, units.degC)
room2 = sim.thermal.add(ThermalProcess.room('room2',
                                            50*units.meter*units.meter,
                                            2.5*units.metre,
                                            units.convert(celsius, units.kelvin)))

celsius = units(5, units.degC)
outside = sim.thermal.add(
    ConstantTemperatureProcess('outside', units.convert(celsius, units.kelvin)))

sim.thermal.add(ThermalCoupling('room1 to outside',