Skip to content

Commit

Permalink
[samples] Avoid import errors for graphviz draw
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Sep 1, 2024
1 parent d276bb0 commit a05281f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions samples/python/reactors/mix1.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
# Create two mass flow controllers connecting the upstream reservoirs to the
# mixer, and set their mass flow rates to values corresponding to
# stoichiometric combustion.
mfc1 = ct.MassFlowController(res_a, mixer, mdot=rho_a*2.5/0.21)
mfc2 = ct.MassFlowController(res_b, mixer, mdot=rho_b*1.0)
mfc1 = ct.MassFlowController(res_a, mixer, mdot=rho_a*2.5/0.21, name="Air inlet")
mfc2 = ct.MassFlowController(res_b, mixer, mdot=rho_b*1.0, name="Fuel inlet")

# %%
# Connect the mixer to the downstream reservoir with a valve.
outlet = ct.Valve(mixer, downstream, K=10.0)
outlet = ct.Valve(mixer, downstream, K=10.0, name="Valve")

sim = ct.ReactorNet([mixer])

Expand All @@ -84,4 +84,8 @@
# %%
# Show the network structure
# --------------------------
diagram = sim.draw(print_state=True, species="X")
try:
diagram = sim.draw(print_state=True, species="X")
diagram.view("mix1.gv")
except ImportError as err:
print(f"Unable to show network structure:\n{err}")
10 changes: 7 additions & 3 deletions samples/python/reactors/reactor2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
# conduct heat

# add a flexible wall (a piston) between r2 and r1
w = ct.Wall(r2, r1, A=1.0, K=0.5e-4, U=100.0)
w = ct.Wall(r2, r1, A=1.0, K=0.5e-4, U=100.0, name="Piston")

# heat loss to the environment. Heat loss always occur through walls, so we
# create a wall separating r2 from the environment, give it a non-zero area,
# and specify the overall heat transfer coefficient through the wall.
w2 = ct.Wall(r2, env, A=1.0, U=500.0)
w2 = ct.Wall(r2, env, A=1.0, U=500.0, name="External Wall")

sim = ct.ReactorNet([r1, r2])

Expand Down Expand Up @@ -118,4 +118,8 @@
# %%
# Show the final state
# --------------------
sim.draw(print_state=True, species="X")
try:
diagram = sim.draw(print_state=True, species="X")
diagram.view("reactor2.gv")
except ImportError as err:
print(f"Unable to show network structure:\n{err}")

0 comments on commit a05281f

Please sign in to comment.