Skip to content

Commit

Permalink
Added presscontrol (EnvPress) environment
Browse files Browse the repository at this point in the history
  • Loading branch information
manjavacas committed Sep 9, 2024
1 parent dbe5df8 commit dcb2dd1
Show file tree
Hide file tree
Showing 12 changed files with 655 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BRANCH ?= foo
BRANCH ?= pid

all: cleanmetrics run
gencor: gen cor
rand:
./rand_controller.py
run:
Expand Down
14 changes: 5 additions & 9 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
id: td3-lr001-b2
id: ppo-press
tasks:
# - train
- test
env:
name: branch_2
name: presscontrol
params:
max_deviation: 40
check_done_time: 500
control_horizon: 10
render_mode: "pressures"
algorithm:
name: TD3
name: PPO
params:
stats_window_size: 1
learning_rate: 0.001
train_params:
total_timesteps: 50000
eval_freq: 10000
total_timesteps: 10000
eval_freq: 2000
n_eval_episodes: 1
wrappers:
- norm_obs
Expand Down
2 changes: 1 addition & 1 deletion examples/drl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import melgym
import gymnasium as gym
Expand Down
2 changes: 1 addition & 1 deletion examples/plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import matplotlib.pyplot as plt
import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion examples/rand_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import melgym
import gymnasium as gym
Expand Down
2 changes: 1 addition & 1 deletion examples/stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import os
import pandas as pd
Expand Down
10 changes: 10 additions & 0 deletions melgym/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
}
)

register(
id='presscontrol',
entry_point='melgym.envs:EnvPress',
kwargs={
'input_file': 'presscontrol.inp',
'n_actions': 1,
'controlled_cvs': ['CV002']
}
)

register(
id='branch_1',
entry_point='melgym.envs:EnvHVAC',
Expand Down
135 changes: 135 additions & 0 deletions melgym/data/presscontrol.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
* ENV -----------> VOL
* ^ |
* |-------PID------|

**********************************************************************************************
* MELGEN INPUT *
**********************************************************************************************

*EOR* MELGEN

TITLE PRESSCONTROL

**********************************************************
* NGC INPUT *
**********************************************************

NCG001 N2 4
NCG002 O2 5

**********************************************************
* CV INPUT *
**********************************************************

CV00100 ENV 2 0 1
CV00101 0 -1
CV001A0 3
CV001A1 PVOL 101235.0
CV001A2 TATM 297.0
CV001A3 RHUM 0.6
CV001A4 MLFR.4 0.78
CV001A5 MLFR.5 0.22

CV001B1 0.0 0.0
CV001B2 10.0 1000.0

******

CV00200 VOL 2 0 1
CV00201 0 0
CV002A0 3
CV002A1 PVOL 101000.0
CV002A2 TATM 297.0
CV002A3 RHUM 0.6
CV002A4 MLFR.4 0.78
CV002A5 MLFR.5 0.22

CV002B1 0.0 0.0
CV002B2 10.0 1000.0

**********************************************************
* FL INPUT *
**********************************************************

FL00100 LEAK-IN 001 002 3.0 3.0
FL00101 1.0 1.0 1.0
FL00102 3
FL001S0 1.0 1.0 1.0
* FL001T0 2 001

* CF00100 VEL-IN EQUALS 1 1.0
* CF00110 0.0 1.0 TIME

**

FL00200 EXHAUST 002 001 3.0 3.0
FL00201 1.0 1.0 1.0
FL00202 3
FL002S0 1.0 1.0 1.0
FL002T0 2 002

CF00200 VEL-OUT EQUALS 1 1.0
CF00210 1.0 0.0 CFVALU.7 * 5-constant, 6-PID, 7-DRL

** Control - Constant **

CF00500 CONSTANT EQUALS 1 5.0
CF00510 0.0 1.0 TIME

** Control - PID **

CF00300 SETPOINT EQUALS 1 1.0
CF00310 0.0 101000.0 TIME

CF00400 ERROR ADD 2 1.0
CF00410 1.0 0.0 CVH-P.2
CF00411 -1.0 0.0 CFVALU.3

CF00600 VEL-OUT PID 1 1.0
CF00603 0.005 0.002 0.001
CF00610 1.0 0.0 CFVALU.4

** Control - DRL **

CF00700 CONTROLLER MULTIPLY 2 1.0
CF00710 1.0 0.0 CFVALU.998
CF00715 1.0 0.0 CFVALU.999

CF99800 FOO-CF-1 EQUALS 1 1.0
CF99810 0.0 1.0 TIME

CF99900 FOO-CF-2 EQUALS 1 1.0
CF99910 0.0 1.0 TIME

**********************************************************
* EDF INPUT *
**********************************************************

EDF00100 OUTPUT 1 WRITE
EDF00101 OUTPUT.DAT
EDF00102 8E20.12
EDF00110 1. 10.
EDF001A1 CVH-P.2

. * END MELGEN

**********************************************************************************************
* MELCOR INPUT *
**********************************************************************************************

*EOR* MELCOR

WARNINGLEVEL 0

TITLE PRESSCONTROL

CPULEFT 100.
CPULIM 100000.
CYMESF 100 100

TEND 3e4

* TIME DTMAX DTMIN DTEDT DTPLT DTRST
TIME1 0.0 10.0 0.1 10.0 100.0 10.0

. * END MELCOR
1 change: 1 addition & 0 deletions melgym/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
"""

from melgym.envs.hvac import EnvHVAC
from melgym.envs.pressure import EnvPress
Loading

0 comments on commit dcb2dd1

Please sign in to comment.