From 9a77f1d33ef92ae4c912bea10bce92820678e418 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Thu, 11 Jul 2024 13:22:02 +0200 Subject: [PATCH] [bugfixes][Motor] Added timestep sanitisation --- classes/bays/Motor.m | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/classes/bays/Motor.m b/classes/bays/Motor.m index 3a8af1f..e4687cc 100644 --- a/classes/bays/Motor.m +++ b/classes/bays/Motor.m @@ -89,29 +89,26 @@ classdef Motor < Bay error(strcat('Unable to find engine: ', obj.name)); end + obj.length = chosenMotor.L; + [obj.time, iUniqueTime] = unique(chosenMotor.t); + obj.thrust = chosenMotor.T(iUniqueTime); + obj.propellantMass = chosenMotor.m(iUniqueTime); + obj.structureMass = chosenMotor.mc; + obj.isHRE = contains(obj.name, 'HRE'); - + if obj.isHRE - obj.length = chosenMotor.L; - obj.tankLength = chosenMotor.Ltank; - obj.time = chosenMotor.t; - obj.thrust = chosenMotor.T; - obj.fuelMass = chosenMotor.mFu; - obj.oxidizerMass = chosenMotor.mOx; - obj.structureMass = chosenMotor.mc; - obj.propellantMass = chosenMotor.m; - obj.inertia = [chosenMotor.Ixx;chosenMotor.Iyy;chosenMotor.Izz]; - obj.xCg = chosenMotor.xcg; - obj.pe = chosenMotor.Pe; - obj.ae = chosenMotor.Ae; - obj.fuselageMass = chosenMotor.mFus; - else - obj.length = chosenMotor.L; - obj.time = chosenMotor.t; - obj.thrust = chosenMotor.T; - obj.propellantMass = chosenMotor.m; - obj.structureMass = chosenMotor.mc; + obj.tankLength = chosenMotor.Ltank; + obj.fuelMass = chosenMotor.mFu; + obj.oxidizerMass = chosenMotor.mOx; + inertiaRaw = [chosenMotor.Ixx;chosenMotor.Iyy;chosenMotor.Izz]; + obj.inertia = inertiaRaw(:, iUniqueTime); + obj.xCg = chosenMotor.xcg(iUniqueTime); + obj.pe = chosenMotor.Pe(iUniqueTime); + obj.ae = chosenMotor.Ae; + obj.fuselageMass = chosenMotor.mFus; end + if isempty(obj.cutoffTime) || obj.cutoffTime > obj.time(end) obj.cutoffTime = obj.time(end); end -- GitLab