def create(self, num, model, vlow=0.95, vup=1.05):
        counter = self.eid_counters.get(model, count())

        entities = []

        for i in range(num):
            eid = '%s_%s' % (model, next(counter))  # entity ID

            if self.verbose: print('{0}, {1}, {2}, {3}'.format(self.uri_to_extracted_fmu, self.model_name, self.logging_on, self.time_diff_resolution))

            fmu = fmipp.FMUCoSimulationV1( self.uri_to_extracted_fmu, self.model_name,
                self.logging_on, self.time_diff_resolution )
            self._entities[eid] = fmu

            status = self._entities[eid].instantiate( self.instance_name, self.timeout,
                self.visible, self.interactive )
            assert status == fmipp.fmiOK

            status = self._entities[eid].initialize( self.start_time*self.sec_per_mt,
                self.stop_time_defined, self.stop_time*self.sec_per_mt )
            assert status == fmipp.fmiOK

            self.data[eid] = { 'tap': 0 }
            self.set_values( eid, { 'u3': 1., 'u4': 1., 'vlow': vlow, 'vup': vup }, 'input' )

            self.is_responsive[eid] = True
            self.wakeup_time[eid] = None

            # Handling tracking internal fmu times
            self.fmutimes[eid] = self.start_time*self.sec_per_mt

            entities.append( { 'eid': eid, 'type': model, 'rel': [] } )

        return entities
    def create(self, num, model):
        counter = self.eid_counters.get(model, count())

        entities = []

        for i in range(num):
            eid = '%s_%s' % (model, next(counter))  # entity ID

            if self.verbose:
                print('{0}, {1}, {2}, {3}'.format(self.uri_to_extracted_fmu,
                                                  self.model_name,
                                                  self.logging_on,
                                                  self.time_diff_resolution))

            fmu = fmipp.FMUCoSimulationV1(self.uri_to_extracted_fmu,
                                          self.model_name, self.logging_on,
                                          self.time_diff_resolution)
            self._entities[eid] = fmu

            status = self._entities[eid].instantiate(self.instance_name,
                                                     self.timeout,
                                                     self.visible,
                                                     self.interactive)
            assert status == fmipp.fmiOK

            status = self._entities[eid].initialize(
                self.start_time * self.sec_per_mt, self.stop_time_defined,
                self.stop_time * self.sec_per_mt)
            assert status == fmipp.fmiOK

            self.data[eid] = {
                'U3': self.get_value(eid, 'ElmTerm_LVBus3_m:u'),
                'U4': self.get_value(eid, 'ElmTerm_LVBus4_m:u'),
                'current_tap': self.current_tap
            }

            # Handling tracking internal fmu times
            self.fmutimes[eid] = self.start_time * self.sec_per_mt

            entities.append({'eid': eid, 'type': model, 'rel': []})

        return entities
Beispiel #3
0
    def __init__(
        self, name, group, inputs_map, outputs, init_values
    ):  # If needed you can pass more values to your node constructor.
        super(MyNode, self).__init__(
            name, group, inputs_map, outputs, init_values
        )  # Keep this line, it triggers the parent class method.

        # This is where you define the attribute of your model, this one is pretty basic.
        # FMU loading
        work_dir = os.path.split(
            os.path.abspath(__file__))[0]  # define working directory
        model_name = 'Exercise1D'  # define FMU model name
        path_to_fmu = os.path.join(work_dir,
                                   model_name + '.fmu')  # path to FMU
        uri_to_extracted_fmu = fmipp.extractFMU(path_to_fmu,
                                                work_dir)  # extract FMU
        logging_on = False
        time_diff_resolution = 1e-9
        self.fmu = fmipp.FMUCoSimulationV1(uri_to_extracted_fmu, model_name,
                                           logging_on, time_diff_resolution)
        print('successfully loaded the FMU')

        ## FMU instantiation
        start_time = 0.
        stop_time = 3600. * 24.  # 24 hours
        self.step_size = 3600  # 1 hour
        self.tempo = self.step_size
        instance_name = "eplus_fmu_test"
        visible = False
        interactive = False
        status = self.fmu.instantiate(instance_name, start_time, visible,
                                      interactive)
        assert status == fmipp.fmiOK
        print('successfully instantiated the FMU')

        ## FMU initialization
        stop_time_defined = True
        status = self.fmu.initialize(start_time, stop_time_defined, stop_time)
        assert status == fmipp.fmiOK
        print('successfully initialized the FMU')
Beispiel #4
0
    def __init__(self):
        super().__init__(
        )  # Keep this line, it triggers the parent class __init__ method.

        # This is where you define the attribute of your model, this one is pretty basic.
        # FMU loading
        work_dir = os.path.split(
            os.path.abspath(__file__))[0]  # define working directory
        #self.ModelName = 'Residential_DH'  # define FMU model name
        self.modelName = 'Residential_DH_2'
        path_to_fmu = os.path.join(work_dir,
                                   self.modelName + '.fmu')  # path to FMU
        uri_to_extracted_fmu = fmipp.extractFMU(path_to_fmu,
                                                work_dir)  # extract FMU
        logging_on = False
        time_diff_resolution = 1e-9
        self.fmu = fmipp.FMUCoSimulationV1(uri_to_extracted_fmu,
                                           self.modelName, logging_on,
                                           time_diff_resolution)
        print('successfully loaded the FMU')

        ## FMU instantiation
        start_time = 3600. * 24. * 0.
        stop_time = 3600. * 24. * 31.  # 24 hours
        self.step_size = 3600.  # 1/6 hour
        self.tempo = start_time  # self.step_size
        instance_name = "eplus_fmu_test"
        visible = False
        interactive = False
        status = self.fmu.instantiate(instance_name, start_time, visible,
                                      interactive)
        assert status == fmipp.fmiOK
        print('successfully instantiated the FMU')

        ## FMU initialization
        stop_time_defined = True
        status = self.fmu.initialize(start_time, stop_time_defined, stop_time)
        assert status == fmipp.fmiOK
        print('successfully initialized the FMU')
Beispiel #5
0
    def __init__(self):
        super().__init__(
        )  # Keep this line, it triggers the parent class __init__ method.

        # This is where you define the attribute of your model, this one is pretty basic.
        # FMU loading
        work_dir = os.path.split(
            os.path.abspath(__file__))[0]  # define working directory
        model_name = 'COGplant'  # define FMU model name
        path_to_fmu = os.path.join(work_dir,
                                   model_name + '.fmu')  # path to FMU
        uri_to_extracted_fmu = fmipp.extractFMU(path_to_fmu,
                                                work_dir)  # extract FMU
        logging_on = False
        time_diff_resolution = 1e-9
        self.fmu = fmipp.FMUCoSimulationV1(uri_to_extracted_fmu, model_name,
                                           logging_on, time_diff_resolution)
        print('successfully loaded the FMU')

        ## FMU instantiation
        start_time = 0.
        stop_time = 450. * 8. * 24 * 31.  # 24 hours
        self.step_size = 3600  # 450. # 1 hour
        self.tempo = self.step_size
        instance_name = "trnsys_fmu_test"
        visible = False
        interactive = False
        status = self.fmu.instantiate(instance_name, start_time, visible,
                                      interactive)
        assert status == fmipp.fmiOK
        print('successfully instantiated the FMU')

        ## FMU initialization
        stop_time_defined = True
        status = self.fmu.initialize(start_time, stop_time_defined, stop_time)
        assert status == fmipp.fmiOK
        #fmu.setRealValue( 'Treturn', 40. ) # Very important to initialize
        print('successfully initialized the FMU')
Beispiel #6
0
import fmipp
import os.path
import math

work_dir = os.path.split(
    os.path.abspath(__file__))[0]  # define working directory
model_name = 'Exercise1D'  # define FMU model name

path_to_fmu = os.path.join(work_dir, model_name + '.fmu')  # path to FMU
uri_to_extracted_fmu = fmipp.extractFMU(path_to_fmu, work_dir)  # extract FMU

logging_on = False
time_diff_resolution = 1e-9
fmu = fmipp.FMUCoSimulationV1(uri_to_extracted_fmu, model_name, logging_on,
                              time_diff_resolution)

print('successfully loaded the FMU')

start_time = 0.
stop_time = 3600. * 24.  # 24 hours

instance_name = "eplus_fmu_test"
visible = False
interactive = False
status = fmu.instantiate(instance_name, start_time, visible, interactive)
assert status == fmipp.fmiOK

print('successfully instantiated the FMU')

stop_time_defined = True
status = fmu.initialize(start_time, stop_time_defined, stop_time)