Skip to content

Commit

Permalink
Added pipe switch
Browse files Browse the repository at this point in the history
  • Loading branch information
luca7084 committed Jun 29, 2023
1 parent f675250 commit 36884f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions rocket_twin/notebooks/test_sequences.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"source": [
"#Run fuelling sequence (transfers fuel from ground tank to rocket tank until it is full)\n",
"\n",
"s2 = [{'name' : 'fuel', 'type' : 'transient', 'init' : {'g_tank.w_out_temp' : 1.}, 'dt' : 0.1, 'Tf' : 5., 'stop' : 'rocket.tank.weight_p == rocket.tank.weight_max'}]\n",
"s2 = [{'name' : 'fuel', 'type' : 'transient', 'init' : {'g_tank.w_out_temp' : 1., 'pipe.is_open' : True},\n",
" 'dt' : 0.1, 'Tf' : 5., 'stop' : 'rocket.tank.weight_p == rocket.tank.weight_max'}]\n",
"run_sequences(sys, s2)"
]
},
Expand Down Expand Up @@ -142,7 +143,7 @@
"source": [
"#Run flight sequence (turns rocket on and discards rocket tank fuel until it is empty)\n",
"\n",
"s3 = [{'name' : 'flight', 'type' : 'transient', 'init' : {'rocket.tank.w_out_temp' : 0.5, 'g_tank.w_out_temp' : 0., 'rocket.dyn.switch' : True},\n",
"s3 = [{'name' : 'flight', 'type' : 'transient', 'init' : {'rocket.tank.w_out_temp' : 0.5, 'pipe.is_open' : False, 'rocket.dyn.switch' : True},\n",
" 'dt' : 0.1, 'Tf' : 10., 'stop' : 'rocket.tank.weight_p == 0.'}]\n",
"run_sequences(sys, s3)"
]
Expand Down Expand Up @@ -171,6 +172,16 @@
"sys.rocket.dyn.inwards"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "602b8d98-a7e8-4660-aaea-7a5a4f59ac63",
"metadata": {},
"outputs": [],
"source": [
"sys.g_tank.inwards"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
9 changes: 8 additions & 1 deletion rocket_twin/systems/tank/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Pipe(System):
------
w_in [kg/s]: float,
mass flow of fuel entering the pipe
is_open: boolean,
whether the pipe is open or closed
Outputs
------
Expand All @@ -17,8 +19,13 @@ class Pipe(System):

def setup(self):

self.add_inward("is_open", False, desc="Whether the pipe is open or not", unit='')
self.add_inward("w_in", 0.0, desc="Fuel income rate", unit="kg/s")

self.add_outward("w_out", 0.0, desc="Fuel exit rate", unit="kg/s")

def compute(self):
self.w_out = self.w_in

if self.is_open == False:
self.parent.g_tank.w_out_temp = 0.
self.w_out = self.w_in

0 comments on commit 36884f6

Please sign in to comment.