Skip to content

Commit

Permalink
modify the eplus
Browse files Browse the repository at this point in the history
  • Loading branch information
Huang committed Nov 7, 2019
1 parent 44ddc28 commit 5b9e489
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion PNNLCodes/CoSim/B_Office_20181228.idf
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ RunPeriod,
8, !- Begin Month
1, !- Begin Day of Month
8, !- End Month
2, !- End Day of Month
1, !- End Day of Month
Monday, !- Day of Week for Start Day
No, !- Use Weather File Holidays and Special Days
No, !- Use Weather File Daylight Saving Period
Expand Down
82 changes: 47 additions & 35 deletions PNNLCodes/CoSim/mpc_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,10 @@ def write_port_file(port,host):



while index<1:
while 1:


ele_m=matlab.double(ele[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

gas_m=matlab.double(gas[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])




qin=[]

for i in range(1,6):
qin.append(prediction['top'+str(i)].values.tolist()[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

for i in range(1,6):
qin.append(prediction['mid'+str(i)].values.tolist()[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

for i in range(1,6):
qin.append(prediction['bot'+str(i)].values.tolist()[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

qin.append(prediction['basement'].values.tolist()[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

qin_m=matlab.double(qin)

tout_m=matlab.double(tout[index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

# print len(qin[1][index*int(control_horizon_length/60):index*int(control_horizon_length/60)+1440/int(control_horizon_length/60)])

Expand All @@ -141,23 +119,57 @@ def write_port_file(port,host):
if len(arry)>6:
time=float(arry[5])
mssg = '%r %r %r 0 0 %r' % (vers, flag, 38, time)
tini=[]
for i in range(7,7+16):
tini.append(float(arry[i]))
print tini
# print len(tini)
tini_m=matlab.double([tini])


# print mssg
if index%(int(control_horizon_length/60))==0:

start_t=index/int(control_horizon_length/60)

end_t=start_t+1440/int(control_horizon_length/60)

print index

print start_t

print end_t


ele_m=matlab.double(ele[start_t:end_t])

gas_m=matlab.double(gas[start_t:end_t])

tini=[]
for i in range(7,7+16):
tini.append(float(arry[i]))
tini_m=matlab.double([tini])


qin=[]

for i in range(1,6):
qin.append(prediction['top'+str(i)].values.tolist()[start_t:end_t])

for i in range(1,6):
qin.append(prediction['mid'+str(i)].values.tolist()[start_t:end_t])

for i in range(1,6):
qin.append(prediction['bot'+str(i)].values.tolist()[start_t:end_t])

qin.append(prediction['basement'].values.tolist()[start_t:end_t])

qin_m=matlab.double(qin)

tout_m=matlab.double(tout[start_t:end_t])

# print index
set=[]
tset= eng.func_EDC_CoSim_test(samp_time/60.,ele_m,gas_m,tout_m,qin_m,tini_m)
print tset
for i in range(16):
set.append(round(24+np.sin(index/288.0*2*3.14*(rd.uniform(-0.5,0.5)+1))*1,2))
set=[]
tset= eng.func_EDC_CoSim_test(samp_time/60.,ele_m,gas_m,tout_m,qin_m,tini_m)
# print tset


for i in range(16):
mssg = mssg + ' ' + str(set[i])+ ' ' + str(set[i])
mssg = mssg + ' ' + str(tset[i][0])+ ' ' + str(tset[i][0])
mssg = mssg+ ' ' + str(0.3) + ' ' + str(0.3)+ ' ' +str(0.3)+ ' ' +str(0.3)+ ' ' +str(2500)+ ' ' +str(0)

mssg = mssg+'\n'
Expand Down
22 changes: 11 additions & 11 deletions PNNLCodes/CoSim/utilSocket.log
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
*** BCVTB client log file.
*************************.
Writing to socket at time = 6.000000e+01
Writing to socket at time = 8.670000e+04
Assembling buffer.
Write to socket with fd = 180
Buffer = 2 0 17 0 0 6.000000000000000e+01 2.497500000000000e+01 2.400021172423926e+01 2.399991664623647e+01 2.399993029044591e+01 2.400014348948186e+01 2.400006205288541e+01 2.400000274441147e+01 2.399990345692441e+01 2.399994605164617e+01 2.399971498428790e+01 2.399999697437331e+01 2.399997458346420e+01 2.399994159191019e+01 2.399997445456546e+01 2.399997705348641e+01 2.399999634186236e+01 2.399999269463097e+01
Write to socket with fd = 176
Buffer = 2 0 17 0 0 8.670000000000000e+04 2.495000000000000e+01 2.396643934823365e+01 2.400053032636349e+01 2.399992822417956e+01 2.316506262722996e+01 2.382715325789802e+01 2.400026650335525e+01 2.382546031459006e+01 2.399994318344473e+01 2.357880645147437e+01 2.399999422928671e+01 2.399997320503082e+01 2.399984926976600e+01 2.399997314234871e+01 2.399997353355216e+01 2.399999489631016e+01 2.171757794426900e+01

Wrote 408 characters to socket.
Reading from socket.
In readbufferfromsocket: Read -1 chars, maximum is 22458.
Error reading: WSAGetLastError = 10054
In readbufferfromsocket: Read 0 chars, maximum is 22458.
Error reading: WSAGetLastError = 0
Finished exchanging data with socket: simTimRea=0.000000e+00, flag=-1.
Assembling buffer.
Write to socket with fd = 180
Write to socket with fd = 176
Buffer = 2 -20

Error writing to socket: Return value = -1.
Error writing to socket: WSAGetLastError = 10054
sendclientmessage wrote flag -20, return value = -1.
Wrote 7 characters to socket.
sendclientmessage wrote flag -20, return value = 7.
In readbufferfromsocket: Read -1 chars, maximum is 22458.
Assembling buffer.
Write to socket with fd = 180
Write to socket with fd = 176
Buffer = 2 -1

Error writing to socket: Return value = -1.
Error writing to socket: WSAGetLastError = 10054
Error writing to socket: WSAGetLastError = 10053
sendclientmessage wrote flag -1, return value = -1.

0 comments on commit 5b9e489

Please sign in to comment.