{"id":20053781,"url":"https://github.com/kevinksytrd/pycosim_old","last_synced_at":"2026-05-18T00:32:42.481Z","repository":{"id":141759646,"uuid":"288418658","full_name":"kevinksyTRD/pycosim_old","owner":"kevinksyTRD","description":"pycosim is a Python package that provides a user-friendly interface to the COSIM-CLI from Open Simulation Platform. ","archived":false,"fork":false,"pushed_at":"2020-09-24T11:33:29.000Z","size":11166,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-14T14:03:10.666Z","etag":null,"topics":["co-simulation","python","simulation"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinksyTRD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-08-18T09:58:36.000Z","updated_at":"2022-10-13T09:10:18.000Z","dependencies_parsed_at":"2024-01-24T11:58:35.528Z","dependency_job_id":null,"html_url":"https://github.com/kevinksyTRD/pycosim_old","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"a604144bd8867eecba00d88b743cd7ae1dea486e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kevinksyTRD/pycosim_old","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinksyTRD%2Fpycosim_old","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinksyTRD%2Fpycosim_old/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinksyTRD%2Fpycosim_old/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinksyTRD%2Fpycosim_old/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinksyTRD","download_url":"https://codeload.github.com/kevinksyTRD/pycosim_old/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinksyTRD%2Fpycosim_old/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33160476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["co-simulation","python","simulation"],"created_at":"2024-11-13T12:29:35.912Z","updated_at":"2026-05-18T00:32:38.355Z","avatar_url":"https://github.com/kevinksyTRD.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyCoSim\n![PyCoSim](/resources/PyCoSimTitle.svg)\n\npycosim is a package for running co-simulation using cosim-cli from [Open Simulation Project](https://open-simulation-platform.github.io/). It provides an user friendly interface for creating the simulation setups such as logging configuration, scenario, interfaces between models and initial values. \n\n## Features\n- Importing an FMU, getting information of the model description and running a single FMU simulation,\n- Importing a system configuration, configuring output logging and scenario, running co-simulation and retrieving the results,\n\n## Getting Started\n### Prerequisite\n- Operation system: Windows 7 or later \n- Python \u003e 3.6\n### Installation\nThe package can be installed by `pip`:\n```bash\n\u003e pip install pyCOSIM --extra-index-url=https://test.pypi.org/simple/\n```\n### Basic Usage\nThe package provides a SimulationConfiguration class that manages the system configuration and the settings for the simulation, deploys necessary files and run simulations.\nTo use the class, import the class as follows:\n```python\nfrom pycosim.simulation import SimulationConfiguration \n```\nA target system can be built up bottom-up from scratch or imported using a system structure file that is usually named, `OspSystemStruct.xml`.\nImporting file can be done as follows:\n```python\nimport os\nfrom pycosim.simulation import SimulationConfiguration \n\npath_or_str_content_of_system_structure_file = os.path.join('base', 'system')  # Path where the systm structure file if found\npath_to_dir_for_fmu = 'base' # Path where the fmus are found\n\nsim_config = SimulationConfiguration(\n    system_structure=path_or_str_content_of_system_structure_file,\n    path_to_fmu=path_to_dir_for_fmu,\n)\n\n\n``` \nNote that the path to the directories that contain all the relevant FMUs should be provided together with the source for the system structure file.\nWhen the system is configured, you can run the simulation for a given simulation time with default settings:\n```python\nfrom pycosim.simulation import SimulationConfiguration \n\nsim_config = SimulationConfiguration(\n    system_structure='system_path',\n    path_to_fmu='base_path',\n)\n\noutput = sim_config.run_simulation(duration=10.0)\nresult_comp1 = output.result.get('comp1')  # Get result DataFrame for the component, naemd 'comp1'\nlog = output.log                           # Logging during the simulation\npath_to_output_files = output.output_file_path #Path for the ouput files\n```\nDefault setting for the simulation is:\n- No scenario\n- No logging configuration (All variables will be logged at each time step.)\n- The system structure and output files are saved in the same directory as the temporary one where FMUs are deployed.\n- Only warning from simulation setting up and progress messages are logged.\n\nThe `run_simulation` method returns NamedTuple instance of output. It has three members:\n- result: The result of the simulation given in a dictionary instance. The dictionary has key of names of the components in the system and DataFrame as value for each key that contains all the numerical outputs.\n- log: Logged message during setting up and running simulation\n- output_file_path: Path to the temporary directory that contains fmus, settings and output csv files.\n \n### Scenario configuration\nA scenario is a collection of events that override / bias / reset a variable of components in the target system. A scenario can be created as follows:\n```python\n# Creating a scenario instance\nimport os\nfrom pyOSPParser.scenario import OSPScenario, OSPEvent\nfrom pycosim.simulation import SimulationConfiguration\n\nsim_config = SimulationConfiguration(\n    system_structure='system_path',\n    path_to_fmu='base_path',\n)\n\nsimulation_end_time = 10\nscenario = OSPScenario(name='test_scenario', end=simulation_end_time)\n\n# Adding an event to the scenario\nscenario.add_event(OSPEvent(\n    time=5,  # Time when the event happens\n    model='component',  # Name_of_the_component\n    variable='variable1', # name_of_the_variable,\n    action=OSPEvent.OVERRIDE, # Type of actions among OVERRIDE, BIAS, RESET\n    value=19.4 # Value (only for OVERRIDE and BIAS)\n))\n\nsim_config.scenario = scenario\n``` \nFinally, the scenario instance can be assigned to the system configuration.\n\n### Logging configuration\nA logging configuration specifies which variables will be logged as output of the simulation. A logging configuration can be \ndefined using OspLoggingConfiguration class:\n```python\nfrom pyOSPParser.logging_configuration import OspVariableForLogging, OspSimulatorForLogging, OspLoggingConfiguration\nfrom pycosim.simulation import SimulationConfiguration\n\nsim_config = SimulationConfiguration(\n    system_structure='system',\n    path_to_fmu='base',\n)\n# Create a variable object for logging\nvariable_name = 'variable1'\nvariable = OspVariableForLogging(name=variable_name)\n\n# Create a logging configuration of a component\nname_of_component = 'component1'\nlogging_config_comp = OspSimulatorForLogging(\n    name=name_of_component,\n    decimation_factor=1,\n    variables=[variable]\n)\n\n# Create a logging configuration instance for the system\nlogging_config = OspLoggingConfiguration(simulators=[logging_config_comp])\n\nsim_config.logging_config = logging_config\n```\n\n### Logging level setting\nYou can set the logging level for the messages during setting up and running a simulation. You can do that\nby passing the `LoggingLevel` member when running the simulation. If not specified, it will be 'warning' by default.\n```python\n    from pycosim.simulation import SimulationConfiguration, LoggingLevel\n    \n    sim_config = SimulationConfiguration(\n    system_structure='system',\n    path_to_fmu='base',\n)\n\nsim_config.run_simulation(duration=10.0, logging_level=LoggingLevel.info)\n```  \n\n## License\nCopyright Kevin Koosup Yum, SINTEF Ocean and others 2020\n\nDistributed under the terms of the Apache license 2.0, pycosim is free and open source software.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinksytrd%2Fpycosim_old","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinksytrd%2Fpycosim_old","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinksytrd%2Fpycosim_old/lists"}