Commit 471b895d authored by Greenwood, Scott's avatar Greenwood, Scott
Browse files

reoganized and updated to ensure examples are working

parent 2053ecb6
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -73,32 +73,36 @@ class AutoCSM:
    
if __name__ == "__main__":
    
    # JSON file path
    # json_file_path = '../data/input_specification_v2.json'
    json_file_path = '../data/input_specification_frontier_test.json'
    # Input specification JSON file path
    json_file_path = '../examples/data/input_specification_v0.json'
    
    # Output Modelica file
    # Output location of generated files
    output_path = '../temp'

    # Path to ExaDigiT based project
    project_path = '../method/Modelica/ORNLSupercomputing'
    # Path to the project which uses an AutoCSM language method 
    project_path = '../examples/modelica/GenericCSM'
    
    # Model dependecies
    dependencies = [r'C:/Users/fig/OneDrive - Oak Ridge National Laboratory/proposals/2024_02_FrontierSystemModelAutomation/Publications/2024_AmericaModelicaConference/FrontierTH/package.mo',
          		    r'../../modelica-buildings/Buildings/package.mo',
          		    r'../../TRANSFORM-Library/TRANSFORM/package.mo']
    # Model dependecies: List of libraries needed for FMU generation
    dependencies = [r'../../../Modelica/modelica-buildings/Buildings/package.mo',
          		    r'../../../Modelica/TRANSFORM-Library/TRANSFORM/package.mo']

    # Example usage
    # Instantiate AutoCSM
    csm = AutoCSM(language='modelica', architecture='nested')
    
    # Load teh specification
    csm.set_input_specification(json_file_path)
    
    # Set the path to output created files
    csm.set_output_path(output_path)
    csm.create_architecture()
    
    # This line creates an project with a file structure for the specified language and architecture
    csm.create_architecture() # more notes
    
    # Set the path to the project of interest
    csm.set_project_path(project_path)
    
    # Create the model for export to FMU (i.e., Simulator.mo)
    csm.create_model(uniform=[False,False])
    csm.create_fmu(dependencies)
    
    # auto_csm.set_language('julia')
    # auto_csm.read_input('input_file.txt', 'additional_arg1', param='value')
    # auto_csm.create_model('model_file.txt', option=True)
    # auto_csm.create_fmu('fmu_file.txt', debug=True)
    # Generate the FMU (i.e., Simulator.fmu)
    csm.create_fmu(dependencies)
+2 −2
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ if __name__ == "__main__":
    # Change to your JSON file path
    # Change to your template folder path
    # Change to your desired output directory
    json_file_path = '../../../data/input_specification_v0.json'
    template_folder = '../../../method/Modelica/ExaDigiT_AutoCSM/Templates/TemplateSystem'
    json_file_path = '../../../examples/data/input_specification_v0.json'
    template_folder = '../../../methods/modelica/ExaDigiT_AutoCSM/Templates/TemplateSystem'
    output_path = '../../../temp'   
    main(json_file_path, output_path, template_folder, architecture='nested')
 No newline at end of file
+10 −6
Original line number Diff line number Diff line
@@ -104,13 +104,17 @@ def main(package_list, model_path, output_path, experimentSettings={}, showwindo

if __name__ == "__main__":
    # Dependencies
    package_list = [r'../../../method/Modelica/ExaDigiT_AutoCSM/package.mo',
                    r'../../../method/Modelica/ORNLSupercomputing/package.mo',
                    r'C:/Users/fig/OneDrive - Oak Ridge National Laboratory/proposals/2024_02_FrontierSystemModelAutomation/Publications/2024_AmericaModelicaConference/FrontierTH/package.mo',
         		    r'../../../../modelica-buildings/Buildings/package.mo',
         		    r'../../../../TRANSFORM-Library/TRANSFORM/package.mo']
    package_list = [r'../../../methods/modelica/ExaDigiT_AutoCSM/package.mo',
         		    r'../../../../../Modelica/modelica-buildings/Buildings/package.mo',
         		    r'../../../../../Modelica/TRANSFORM-Library/TRANSFORM/package.mo',
                    r'../../../examples/modelica/GenericCSM/package.mo']
    
    # Path to the pregenerated Simulator.mo file. This must exist.
    model_path = os.path.abspath('../../../temp/Simulator.mo')
    
    if not os.path.exists(model_path):
        raise ValueError(f'The Simulator.mo file must exist before this is run. For example, run modelica_create_model_nested.py and then this file.\n File path searched was: {model_path}')
    
    model_path = r'E:\ExaDigiT\AutoCSM\temp\Simulator.mo'
    output_path = pathlib.Path(model_path).parent
    
    main(package_list, model_path, output_path, showwindow=True)
+4 −5
Original line number Diff line number Diff line
@@ -189,23 +189,22 @@ def main(json_file_path, project_path, base_path, parent_class, output_path, str

if __name__ == "__main__":
    # JSON file path
    json_file_path = '../../../data/input_specification_v1.json'
    # json_file_path = '../../../data/input_specification_v1_complete.json'
    json_file_path = '../../../examples/data/input_specification_v0.json'
    
    # Output Modelica file
    output_path = '../../../temp/Simulator.mo'

    # Path to ExaDigiT AutoCSM based project
    project_path = '../../../method/Modelica/GenericCSM'
    project_path = '../../../examples/modelica/GenericCSM'
    
    # Path to top-level system model folder (dotted path) perhaps not a good one
    base_path = pathlib.Path(project_path).name #'ORNLSupercomputing'
    base_path = pathlib.Path(project_path).name #'GenericCSM'

    # Model to be extended and modified
    parent_class = 'ExaDigiT_AutoCSM.BaseClasses.Tests.PartialTest'

    # Structure path
    structure_path ='../../../method/Modelica/ExaDigiT_AutoCSM/Templates/Structure.mo'
    structure_path ='../../../methods/Modelica/ExaDigiT_AutoCSM/Templates/Structure.mo'
    
    # Create Modelica model file
    main(json_file_path, project_path, base_path, parent_class, output_path, structure_path, uniform=[False,False])
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ class ModelicaMethods:
        
    def create_architecture(self, template_folder=None):
        if template_folder is None:
            template_folder = os.path.abspath(os.path.join(self.base_path, '../../../method/Modelica/ExaDigiT_AutoCSM/Templates/TemplateSystem'))
            template_folder = os.path.abspath(os.path.join(self.base_path, '../../../methods/modelica/ExaDigiT_AutoCSM/Templates/TemplateSystem'))
            
        modelica_create_architecture.main(self.parent.input_specification,
                                          self.parent.output_path,
@@ -28,7 +28,7 @@ class ModelicaMethods:
        
    def create_model(self, structure_path=None, parent_class='ExaDigiT_AutoCSM.BaseClasses.Tests.PartialTest', uniform=[True,True]):
        if structure_path is None:
            structure_path = os.path.abspath(os.path.join(self.base_path, '../../../method/Modelica/ExaDigiT_AutoCSM/Templates/Structure.mo'))
            structure_path = os.path.abspath(os.path.join(self.base_path, '../../../methods/modelica/ExaDigiT_AutoCSM/Templates/Structure.mo'))
            
        self.parent.set_model_path(os.path.abspath(os.path.join(self.parent.output_path,'Simulator.mo')))
        
@@ -47,7 +47,7 @@ class ModelicaMethods:
            dependencies.append(os.path.abspath(os.path.join(self.parent.project_path, 'package.mo')))
            
        if 'ExaDigiT_AutoCSM/package.mo' not in dependencies:
            dependencies.append(os.path.abspath(os.path.join(self.base_path, '../../../method/Modelica/ExaDigiT_AutoCSM/package.mo')))
            dependencies.append(os.path.abspath(os.path.join(self.base_path, '../../../methods/modelica/ExaDigiT_AutoCSM/package.mo')))
        
        if fmu_compiler == 'dymola':
            modelica_create_fmu_dymola.main(dependencies, self.parent.model_path, pathlib.Path(self.parent.model_path).parent, experimentSettings, showwindow=False)
 No newline at end of file
Loading