SenHuang19 / BuildingControlTest

"A Docker setup for building control testing"
3 stars 1 forks source link

Emulator Hanging #4

Closed ajaugust closed 2 years ago

ajaugust commented 2 years ago

The code below was used to simulate one day with a pressure fault. The code runs fine, however the emulator does not advance after initialization, instead it prints the following warnings and hangs. Interestingly, if start_day is changed from 194 to 33 the emulator advances as desired.

Emulator output

jmodelica2_1  | Simulation interval    : 16761600.0 - 16761600.0 seconds.
jmodelica2_1  | Elapsed simulation time: 0.000280857086182 seconds.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 2.94805e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 2.94805e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 6.43639e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 6.43639e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 1.90207e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 1.90207e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 5.16996e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 5.16996e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 8.52351e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] Internal t = 1.67616e+07 and h = 8.52351e-10 are such that t + h = t on the next step. The solver will continue anyway.
jmodelica2_1  | [CVode Warning] The above warning has been issued mxhnil times and will not be issued again for this problem.

Python code

### Minimum failing example
import requests
from tqdm import tqdm

url_eplus = 'http://127.0.0.1:5501'
url_modelica = 'http://127.0.0.1:5001'
start_day = 194

# Init simulation
print('Initializing simulation...')
requests.put(f'{url_eplus}/step', data={'step': 60})

# Set the fault scenario
print('Setting the fault scenario...')
fault = {"floor1_pre": {"value": -25, "fault_time": 86400*start_day}}
requests.put(f'{url_modelica}/fault_scenario', json=fault)

# Advance the emulator to initialize it
print('Initializing the emulator...')
y = requests.post(f'{url_eplus}/advance', json='{}').json()

# Set the simulation start and end times
print('Setting start and end times...')
run_period = 86400
start_sec = start_day*86400
end_sec_run = start_sec + run_period  # end time of the run
end_day = (end_sec_run // 86400) + 1       # need the end time to be an integer day for eplus to be happy
end_sec = end_day*86400
requests.put(f'{url_eplus}/reset', data={'start_time':start_sec, 'end_time':end_sec})

###################################################################
# Iterate the simulation forward in time
###################################################################

# Main simulation loop
for k in tqdm(range(run_period // 60), desc='Running simulation'):

    # Advance the simulation forward one time step
    y = requests.post(f'{url_eplus}/advance', json='{}').json()

    # Print the measurements
    print(y)

Python output

Initializing simulation...
Setting the fault scenario...
Initializing the emulator...
Setting start and end times...
Running simulation:   0%|                                                   | 0/1440 [00:00<?, ?it/s]