Skip to content

Commit

Permalink
i did a thing
Browse files Browse the repository at this point in the history
  • Loading branch information
watchful5406 committed Jul 25, 2024
1 parent 5a999f0 commit 3ffede3
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ def breaker_switch(self):
if "lockout" in model.switches[self.info["control_switch"]]["lights"]:
model.switches[self.info["control_switch"]]["lights"]["lockout"] = not self.info["lockout"]

if "sync" in model.switches[self.info["control_switch"]]["lights"]:
model.switches[self.info["control_switch"]]["lights"]["sync"] = self.info["sync"] #TODO: Make this illuminate only from time of taking to close to breaker closure

self.info["sync"] = False


Expand Down Expand Up @@ -318,7 +321,7 @@ def initialize():

#DG1

Breaker(name="cb_dg1_7",incoming=sources["DG1"])
Breaker(name="cb_dg1_7",incoming=sources["DG1"],custom=True) #has a mode selector
Breaker(name="cb_7dg1",incoming=breakers["cb_dg1_7"],running=busses["7"],closed=True)

breakers["cb_dg1_7"].set_running(breakers["cb_7dg1"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self,name,cs = "",output = "",sa = 500,auto = False,loca = False,tr
"horsepower" : horsepower,
"inertia" : inertia,
}
self.governor_pid = pid.PID(0.3,0.0001,0.001,-0.2,0.2)
self.governor_pid = pid.PIDExperimental(0.19,0,0.1,-0.05,0.05) #pid.PID(0.25,0.001,0.01,-0.2,0.2)
self.accel_pid = pid.PID(0.3,0.0001,0.001,-0.3,0)
#self.exciter_pid = pid.PID(0.05,0.0002,0.002,-0.5,0.5)

Expand Down
19 changes: 19 additions & 0 deletions simulation/models/control_room_columbia/libraries/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,23 @@ def update(self, setpoint, current, dt):
output = (self.Kp * error) + (self.Ki * self.integral) + (self.Kd * derivative)
self.last_error = error
output = max(min(output,self.maximum),self.minimum) #TODO
return output

class PIDExperimental:
def __init__(self, Kp, Ki, Kd,minimum,maximum):
self.Kp = Kp
self.Ki = Ki
self.Kd = Kd
self.last_error = 0
self.integral = 0
self.minimum = minimum
self.maximum = maximum

def update(self, setpoint, current, dt):
error = setpoint-current
derivative = (error-self.last_error)/dt
self.integral += error * dt
output = (self.Kp * error) + (self.Ki * self.integral) + (self.Kd * derivative)
self.last_error = self.Kd * derivative
output = max(min(output,self.maximum),self.minimum) #TODO
return output
47 changes: 45 additions & 2 deletions simulation/models/control_room_columbia/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ class ReactorMode(IntEnum):
"lights" : {
"green" : True,
"red" : False,
"lockout" : True,
"close_permit" : True,
},
"flag" : "green",
},
Expand All @@ -1438,6 +1438,46 @@ class ReactorMode(IntEnum):
},
"flag" : "green",
},
"dg1_voltreg": {
"positions": {
0: 45,
1: 0,
2: -45,
},
"position": 1,
"lights" : {},
"flag" : "green",
},
"cb_dg1_7_mode": {
"positions": {
0: 45,
1: 0,
2: -45,
},
"position": 1,
"lights" : {},
"flag" : "green",
},
"sync_cb_dg1_7": {
"positions": {
0: 45,
1: 0,
2: -45,
},
"position": 1,
"lights" : {},
"flag" : "green",
},
"dg1_gov": {
"positions": {
0: 45,
1: 0,
2: -45,
},
"position": 1,
"lights" : {},
"flag" : "green",
},
"diesel_gen_1": {
"positions": {
0: 45,
Expand All @@ -1463,7 +1503,7 @@ class ReactorMode(IntEnum):
"lights" : {
"green" : True,
"red" : False,
"lockout" : True,
"close_permit" : True,
},
"flag" : "green",
},
Expand Down Expand Up @@ -1612,6 +1652,7 @@ class ReactorMode(IntEnum):

"bus_4_voltage" : 4160,
"main_generator_sync" : 0,
"div_1_sync" : 0,

"rwm_group" : -1,
"rwm_insert_error_1" : -1,
Expand Down Expand Up @@ -2196,6 +2237,7 @@ class ReactorMode(IntEnum):
from simulation.models.control_room_columbia.general_physics import diesel_generator
diesel_generator.initialize()

from simulation.models.control_room_columbia.systems import diesels
from simulation.models.control_room_columbia.systems import safety_relief
from simulation.models.control_room_columbia.systems import irm_srm_positioner
from simulation.models.control_room_columbia.systems import feedwater
Expand Down Expand Up @@ -2231,6 +2273,7 @@ def model_run(delta):
turbine.run()
main_turbine.run()
main_generator.run()
diesels.run()

safety_relief.run()
irm_srm_positioner.run()
Expand Down
19 changes: 19 additions & 0 deletions simulation/models/control_room_columbia/systems/diesels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from simulation.models.control_room_columbia import model
from simulation.models.control_room_columbia.general_physics import ac_power
from simulation.models.control_room_columbia.general_physics import diesel_generator



def run():

if model.switches["cb_dg1_7_mode"]["position"] == 0: #Switch in C.R.
if model.switches["cb_dg1_7"]["position"] == 0:
ac_power.breakers["cb_dg1_7"].open()
elif model.switches["cb_dg1_7"]["position"] == 2 and ac_power.breakers["cb_dg1_7"].info["sync"]:
ac_power.breakers["cb_dg1_7"].close()

if model.switches["dg1_gov"]["position"] == 0:
diesel_generator.dg1.dg["rpm_set"] -= 0.1
elif model.switches["dg1_gov"]["position"] == 2:
diesel_generator.dg1.dg["rpm_set"] += 0.1
4 changes: 4 additions & 0 deletions simulation/models/control_room_columbia/systems/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def initialize():
sync.add_selector("sync_cb_4888","gen_bus","GRID","cb_4888")
synchroscopes.append(sync)

sync = SyncSelector("div_1_sync")
sync.add_selector("sync_cb_dg1_7","DG1","7","cb_dg1_7")
synchroscopes.append(sync)

def run():
for synchroscope in synchroscopes:
synchroscope.check_selectors()

0 comments on commit 3ffede3

Please sign in to comment.