diff --git a/rocket_twin/notebooks/test_sequences.ipynb b/rocket_twin/notebooks/test_sequences.ipynb index 2c68ea2..baecd52 100644 --- a/rocket_twin/notebooks/test_sequences.ipynb +++ b/rocket_twin/notebooks/test_sequences.ipynb @@ -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)" ] }, @@ -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)" ] @@ -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, diff --git a/rocket_twin/systems/tank/pipe.py b/rocket_twin/systems/tank/pipe.py index 59e6e1e..2b3597f 100644 --- a/rocket_twin/systems/tank/pipe.py +++ b/rocket_twin/systems/tank/pipe.py @@ -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 ------ @@ -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 \ No newline at end of file