Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing an FCV initial_setting during simulation #325

Open
astuhlmacher opened this issue Jan 18, 2023 · 1 comment
Open

Changing an FCV initial_setting during simulation #325

astuhlmacher opened this issue Jan 18, 2023 · 1 comment
Assignees

Comments

@astuhlmacher
Copy link

Is it possible to adjust the maximum flow rate setting of an FCV during a simulation? For example, I am interested in controlling a FCV to change the initial_setting of an FCV from 0.5 to 0.4 CMS five hours into a 24 hour simulation.

I thought I may be able to do this through a rule using SimTimeCondition but the flow rate in the simulation is remaining constrained by the original setting of 0.5 CMS and it is above the new limit of 0.4 for t=5-24 hours.

Below I have included the code for the rule I tried to add:

import wntr
import wntr.network.controls as controls

# Create a water network model
inp_file = 'networks/Net3_withFCV.inp' 
wn = wntr.network.WaterNetworkModel(inp_file)
wn.convert_controls_to_rules(priority=3) #convert controls to rules

# Modify the water network model
Nt=24
wn.options.time.duration = Nt*3600 # 24 hour scheduling horizon
wn.options.time.hydraulic_timestep = 2 #every 2 seconds
wn.options.time.report_timestep = 2 #every 2 seconds
wn.options.time.rule_timestep = 3600
wn.options.time.pattern_timestep = 3600 # every 1 hour (demand constant over hour)
wn.options.hydraulic.required_pressure = 14.065 #[m]
wn.options.hydraulic.minimum_pressure = 0 # [m]
wn.options.hydraulic.demand_model = 'PDD' # pressure-driven demand
wn.options.energy.global_efficiency = 75

t=5 # Time period where FCV initial_setting is changed
valve1 = wn.get_link('FCV1')
valve1.initial_status = "ACTIVE"

# Adjust the max flow rate through valve
cond1 = controls.SimTimeCondition(wn, '=', t*3600)
act1v = controls.ControlAction(valve1, 'initial_setting', 0.4)
rule_temp = controls.Rule(cond1, [act1v], name='rule_valve1_t{}'.format(t), priority=6)
wn.add_control('rule_valve1_t{}'.format(t), rule_temp) #add rule

sim = wntr.sim.EpanetSimulator(wn)
results = sim.run_sim()
@kaklise
Copy link
Collaborator

kaklise commented Jan 23, 2023

Can you share the modified Net3 model you used to run this example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants