Skip to content

Commit

Permalink
added a version of parsing data in yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
joan-pijpker committed Oct 11, 2024
1 parent 3a1ddd4 commit 928b36a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configuration/create_runsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

sim_config={row[1]:{row[2]:row[3]}for row in sim_config_ddf.values}

print (sim_config)

tosh=sim_config_ddf[sim_config_ddf['method']=='connect']

run_path='./Desktop/illuminatorclient/configuration/runshfile/'
Expand Down
71 changes: 71 additions & 0 deletions configuration/modelling-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
scenario:
name: "ExampleScenario" # in mosaik so called world
start_time: '2012-01-02 00:00:00' # ISO 8601 start time of the simulation
end_time: '2012-01-02 00:00:10' # duration in seconds
models: # list of models for the energy network
- name: Battery1 # name for the model (must be unique)
type: Battery # name of the model registered in the Illuminator
inputs:
input1: 0 # input-name: initial value, default value will be used if not defined
outputs:
output1: 0
output2: null
parameters:
charge_power_max: 100
discharge_power_max: 200
soc_min: 0.1
soc_max: 0.9
capacity: 1000
states:
initial_soc: 0.5
triggers: # list of triggers for the of another model??. It must be an input, output or state of the model
- capacity
- soc_min
scenario_data: 'path/to/file' #path to the scenario data file for the model. This should be optional
method:
type: connect # can be python for local or connect for remote
location: null
connect_ip: 192.168.0.1
connect_port: 5123
- name: Battery2
type: Battery # models can reuse the same type
inputs:
input1: 0 # input-name: initial value, default value will be used if not defined
outputs:
output1: 0
output2: null
parameters:
charge_power_max: 100
states:
soc: 0.5 # initial value for the state, optional
method:
type: connect # can be python for local or connect for remote
location: null
connect_ip: 192.168.0.2
connect_port: 5123
- name: PV1
type: PV
inputs:
input1: 0 # input-name: initial value, default value will be used if not defined
input2: 0
outputs:
output1: 0
parameters:
power_max: 100
states:
initial_soc: 0.5
method:
type: connect # can be python for local or connect for remote
location: null
connect_ip: 192.168.0.3
connect_port: 5123
connections:
- from: Battery1.output2 # start model, pattern: model_name.output_name/input_name
to: PV1.input1 # end model
- from: Battery2.output
to: PV1.input2
monitor: # a list of models, its inputs, output and states to be monitored and logged
- Battery1.input1 # pattern model_name.state_name
- Battery2.output1 # no duplicates allowed
- PV1.soc # pattern model_name.state_name
- PV1.output1
19 changes: 19 additions & 0 deletions configuration/parse_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import yaml

# Open and load the YAML file
with open('modelling-example.yaml', 'r') as _file:
data = yaml.safe_load(_file)

run_path='./Desktop/illuminatorclient/configuration/runshfile/'
run_model='/home/illuminator/Desktop/Final_illuminator'

for model in data['models']:
model_type = model.get('type')

method = model.get('method', {})
connect_ip = method.get('connect_ip')
connect_port = method.get('connect_port')

if connect_ip and connect_port:
print(f"lxterminal -e ssh illuminator@{connect_ip} '{run_path}run{model_type}.sh {connect_ip} {connect_port} {run_model}'&")

0 comments on commit 928b36a

Please sign in to comment.