diff --git a/missions/2024_Lyra_Roccaraso_September/config/massConfig.m b/missions/2024_Lyra_Roccaraso_September/config/massConfig.m index ace1a116441a764b720d14b65e461bfd221371e2..bd002bab52c07d5b2f1cb9ac187bdd9a3c3a3cbe 100644 --- a/missions/2024_Lyra_Roccaraso_September/config/massConfig.m +++ b/missions/2024_Lyra_Roccaraso_September/config/massConfig.m @@ -2,9 +2,7 @@ mass = Masses(); -mass.noseCone = 0; % [kg] Nosecone Mass -mass.noMotor = 0; % [kg] Total structural Mass - -%mass.noEngine + mass.motor.structure + ... mass.noseCone; -%mass.structure + mass.motor.expM(1); % [kg] Total initial Mass -%mass.noEngine + mass.motor.mc + mass.noseCone + mass.motor.expected; % Total mass (in time) +mass.boat = 0; % [kg] BoatTail Mass +mass.center = 0; % [kg] Center Mass (no motor) +mass.nose = 0; % [kg] Nosecone Mass +mass.fins = 0; % [kg] Finset Mass \ No newline at end of file diff --git a/missions/classes/Config.m b/missions/classes/Config.m index 67d688cc906a7c9dfc77fb75a59e775acaffd190..0ae56e2f49a65a174c8047b9c316188770de4384 100644 --- a/missions/classes/Config.m +++ b/missions/classes/Config.m @@ -10,6 +10,10 @@ classdef(Abstract) Config < handle configName {mustBeTextScalar} end + properties(Access = public) + a = 0; + end + methods(Access = protected) function loadConfig(obj) fileName = obj.configName; diff --git a/missions/classes/Environment.asv b/missions/classes/Environment.asv new file mode 100644 index 0000000000000000000000000000000000000000..32e64319ce3e8e789f7d43ca44604a53fdacd777 --- /dev/null +++ b/missions/classes/Environment.asv @@ -0,0 +1,54 @@ +classdef Environment < Config + %ENVIRONMENT Summary of this class goes here + % Detailed explanation goes here + + properties + lat0 double % [deg] Launchpad latitude + lon0 double % [deg] Launchpad longitude + z0 double % [m] Launchpad Altitude + pin1Length double % [m] Distance from the upper pin to the upper tank cap + pin2Length double % [m] Distance from the lower pin to the lower tank cap + rampLength double % [m] Total launchpad length + temperature double % [deg] Ground temperature + pressure double % [Pa] Ground pressure + rho double % [Kg/m^3] Gorund air density + end + + properties(Dependent) + g0 double % [-] Gravity costant at launch latitude and altitude + pinDistance double % [m] Distance of the upper pin from the rail base (upper pin-boat + boat-rail base) + effectiveRampLength double % [m] Total launchpad length + end + + properties(Access = protected) + configName = 'environmentConfig.m' + mission Mission + motor Motor + end + + methods + function obj = Environment(mission, motor) + arguments + mission Mission = Mission() + motor Motor = Mission() + end + obj.mission = mission; + obj.motor = motor; + if nargin == 0, return; end + obj.loadConfig(); + end + + function g0 = get.g0(obj) + g0 = gravitywgs84(obj.z0, obj.lat0); + end + + function pinDistance = get.pinDistance(obj) + pinDistance = obj.pin1Length + obj.pin2Length ... + + obj.motor.tankLength; + end + + function effectiveRampLength = get.effectiveRampLength(obj) + effectiveRampLength = gravitywgs84(obj.z0, obj.lat0); + end + end +end \ No newline at end of file diff --git a/missions/classes/Environment.m b/missions/classes/Environment.m index 58c5bf218acb296d2f793f72745c1ad419eca676..cd0f2f2e180a71ee4ad85aea98abd770e88a2b4e 100644 --- a/missions/classes/Environment.m +++ b/missions/classes/Environment.m @@ -7,34 +7,48 @@ classdef Environment < Config lon0 double % [deg] Launchpad longitude z0 double % [m] Launchpad Altitude pin1Length double % [m] Distance from the upper pin to the upper tank cap - pin2Length double % [m] Distance from the lower pin to the lower tank cap - rampLength double % [m] Total launchpad length + pin2Length double % [m] Distance from the lower pin to the lower tank cap + rampLength double % [m] Total launchpad length temperature double % [deg] Ground temperature pressure double % [Pa] Ground pressure rho double % [Kg/m^3] Gorund air density end properties(Dependent) - g0 double + g0 double % [-] Gravity costant at launch latitude and altitude + pinDistance double % [m] Distance of the upper pin from the rail base (upper pin-boat + boat-rail base) + effectiveRampLength double % [m] Total launchpad length end properties(Access = protected) configName = 'environmentConfig.m' - mission Mission = Mission() + mission Mission + motor Motor end methods - function obj = Environment(mission) + function obj = Environment(mission, motor) arguments mission Mission = Mission() + motor Motor = Mission() end - obj.mission = mission(); + obj.mission = mission; + obj.motor = motor; if nargin == 0, return; end obj.loadConfig(); end function g0 = get.g0(obj) - g0 = gravitywgs84(obj.z0, obj.lat0); % Gravity costant at launch latitude and altitude + g0 = gravitywgs84(obj.z0, obj.lat0); + end + + function pinDistance = get.pinDistance(obj) + pinDistance = obj.pin1Length + obj.pin2Length ... + + obj.motor.tankLength; + end + + function effectiveRampLength = get.effectiveRampLength(obj) + effectiveRampLength = obj.rampLength - obj.pinDistance; end end end \ No newline at end of file diff --git a/missions/classes/Geometries.m b/missions/classes/Geometries.m index e65e55cce956fb572f7af51e10ce8b4db2456fb0..1f2706deb20b0e5be5a9faef709cfd48c0ef6174 100644 --- a/missions/classes/Geometries.m +++ b/missions/classes/Geometries.m @@ -45,7 +45,7 @@ classdef(InferiorClasses = {?Boat, ?Center, ?Nose, ?Pitot, ?Fins, ?Protuberances end function xCg = get.xCg(obj) - xCg = (obj.motor.totalMass.*(obj.center.noMotorLength + obj.motor.xCg) + ... + xCg = (obj.motor.totalMass.*(obj.center.length + obj.motor.xCg) + ... obj.mass.noMotor*obj.xCgNoMotor)./(obj.motor.totalMass + obj.mass.noMotor); end diff --git a/missions/classes/Masses.m b/missions/classes/Masses.m index 949d9e85eeec556bbb9b1057d955dcbe48093293..5114576a4c86d8e6c19bdd7390daf99d2dd55c2a 100644 --- a/missions/classes/Masses.m +++ b/missions/classes/Masses.m @@ -3,13 +3,16 @@ classdef Masses < Config % Detailed explanation goes here properties - noseCone % [kg] Nosecone Mass - noMotor + boat % [kg] BoatTail Mass + center % [kg] Center Mass (no motor) + nose % [kg] Nosecone Mass + fins % [kg] Finset Mass end properties(Dependent) - total % Total mass (in time) - structure % [kg] Total structural Mass + noMotor % [kg] Total mass (no motor) + structure % [kg] Total structural Mass + total % [kg] Total mass (in time) end properties(Access = protected) @@ -31,14 +34,19 @@ classdef Masses < Config obj.loadConfig(); end - function total = get.total(obj) - total = obj.noMotor + obj.noseCone + ... - obj.motor.totalMass; % [kg] Total initial Mass + function noMotor = get.noMotor(obj) + noMotor = obj.boat + obj.center + ... + obj.nose + obj.fins; end function structure = get.structure(obj) - structure = obj.noMotor + obj.noseCone + ... - obj.motor.structureMass; % [kg] Total structural Mass + structure = obj.noMotor + ... + obj.motor.structureMass; + end + + function total = get.total(obj) + total = obj.noMotor + ... + obj.motor.totalMass; end end end \ No newline at end of file diff --git a/missions/classes/Motor.m b/missions/classes/Motor.m index 5ccc1a52f3c4caa771325e801dbfbb7d59447315..7c3b769ec2f5ef83e7132bed323175d144a8b69e 100644 --- a/missions/classes/Motor.m +++ b/missions/classes/Motor.m @@ -3,27 +3,27 @@ classdef Motor < Config % Detailed explanation goes here properties - name % [-] Motor name - totalLength % [m] Motor + Tank lenght - motorLength % [m] Motor length - tankLength % [m] Tank length - ignitionTime % [s] Ignition transient duration - cutoffTime % [s] Cutoff transient duration - time % [s] Engine time vector - thrust % [N] Engine thrust vector - fuelMass % [kg] Fuel (grain) initial mass - oxidizerMass % [kg] Oxidizer initial mass - propellantMass % [Kg] Propellant Mass (in time) - structureMass % [kg] Engine Structural Mass - fuselageMass % [kg] Fuselage of the engine only - xCg % [m] Engine xcg from tank tip - pe % [Pa] Eflux pressure - ae % [Pa] Eflux Area + name {mustBeTextScalar} = '' % [-] Motor name + motorLength double % [m] Motor length + tankLength double % [m] Tank length + ignitionTime double % [s] Ignition transient duration + cutoffTime double % [s] Cutoff transient duration + time double % [s] Engine time vector + thrust double % [N] Engine thrust vector + fuelMass double % [kg] Fuel (grain) initial mass + oxidizerMass double % [kg] Oxidizer initial mass + propellantMass double % [Kg] Propellant Mass (in time) + structureMass double % [kg] Engine Structural Mass + fuselageMass double % [kg] Fuselage of the engine only + xCg double % [m] Engine xcg from tank tip + pe double % [Pa] Eflux pressure + ae double % [Pa] Eflux Area end properties(Dependent) - totalMass % [kg] Total motor mass - fuselageXCg % [m] xcg of the engine fuselage only from tank tip + totalMass double % [kg] Total motor mass + totalLength double % [m] Motor + Tank lenght + fuselageXCg double % [m] xcg of the engine fuselage only from tank tip end properties(Access = protected) @@ -51,10 +51,15 @@ classdef Motor < Config totalMass = obj.propellantMass + ... obj.structureMass + obj.fuselageMass; end + function fuselageXCg = get.fuselageXCg(obj) fuselageXCg = (obj.motorLength - ... obj.tankLength)/2 + obj.tankLength; end + + function totalLength = get.totalLength(obj) + totalLength = obj.motorLength + obj.tankLength; + end end methods (Access = private) @@ -64,19 +69,18 @@ classdef Motor < Config chosenMotor = motors(strcmp({motors.MotorName}, obj.name)); if isempty(chosenMotor), error(strcat('Unable to find engine: ', obj.name)); end - obj.motorLength = chosenMotor.L; % [m] Engine length - obj.tankLength = chosenMotor.Ltank; % [m] Tank length - obj.totalLength = obj.motorLength + obj.tankLength; - obj.time = chosenMotor.t; % [s] Engine time vector - obj.thrust = chosenMotor.T; % [N] Engine thrust vector - obj.fuelMass = chosenMotor.mFu; % [kg] Fuel (grain) initial mass - obj.oxidizerMass = chosenMotor.mOx; % [kg] Oxidizer initial mass - obj.propellantMass = chosenMotor.m; % [Kg] Propellant Mass (in time) - obj.structureMass = chosenMotor.mc; % [kg] Engine Structural Mass - obj.xCg = chosenMotor.xcg; % [m] Engine xcg from tank tip - obj.pe = chosenMotor.Pe; % [Pa] Eflux pressure - obj.ae = chosenMotor.Ae; % [Pa] Eflux Area - obj.fuselageMass = chosenMotor.mFus; % [kg] Fuselage of the engine onlyp + obj.motorLength = chosenMotor.L; + obj.tankLength = chosenMotor.Ltank; + obj.time = chosenMotor.t; + obj.thrust = chosenMotor.T; + obj.fuelMass = chosenMotor.mFu; + obj.oxidizerMass = chosenMotor.mOx; + obj.propellantMass = chosenMotor.m; + obj.structureMass = chosenMotor.mc; + obj.xCg = chosenMotor.xcg; + obj.pe = chosenMotor.Pe; + obj.ae = chosenMotor.Ae; + obj.fuselageMass = chosenMotor.mFus; end end end \ No newline at end of file diff --git a/tests/argValidation.m b/tests/argValidation.m new file mode 100644 index 0000000000000000000000000000000000000000..96633f8ad9a7f00d4c42f0fb1c77b8c65f3dece4 --- /dev/null +++ b/tests/argValidation.m @@ -0,0 +1,11 @@ +function test(in) + arguments(Input) + in Config {mustBeConfig} + end + disp(in.a); +end + +function mustBeConfig(obj) + if ~isa(obj, 'Config'), error('suca'); + end +end \ No newline at end of file diff --git a/tests/speedBenchmark.asv b/tests/speedBenchmark.asv new file mode 100644 index 0000000000000000000000000000000000000000..1388be0e6f1ef8be1f34f7e9237e143556ce35e9 --- /dev/null +++ b/tests/speedBenchmark.asv @@ -0,0 +1,22 @@ +ms = Mission(true); + +cl = Motor(ms); +st = struct(cl); + +len = length(st.xCg); +a = zeros(1, len); +b = zeros(1, len); + +tic + for i = 1:len + a(i) = cl.xCg(i); + end +classTime = toc; + +tic + for i = 1:len + b(i) = st.xCg(i); + end +structTime = toc; + +disp(strcat('classTime: ', classTime)); \ No newline at end of file diff --git a/tests/speedBenchmark.m b/tests/speedBenchmark.m new file mode 100644 index 0000000000000000000000000000000000000000..5c2c39edc619e9584e9787817643767534da0b94 --- /dev/null +++ b/tests/speedBenchmark.m @@ -0,0 +1,32 @@ +clear; clc; close all; + +ms = Mission(true); + +cl = Motor(ms); +st = struct(cl); + +len = length(st.xCg); +a = zeros(1, len); +b = zeros(1, len); +c = zeros(1, len); +d = zeros(1, len); + +tic +a = cl.xCg; +fprintf('stdAssignment, class: %f s\n', toc); + +tic +c = st.xCg; +fprintf('stdAssignment, struct: %f s\n', toc); + +tic +for i = 1:len + b(i) = cl.xCg(i); +end +fprintf('elementWiseAssignment, class: %f s\n', toc); + +tic +for i = 1:len + d(i) = st.xCg(i); +end +fprintf('elementWiseAssignment, struct: %f s\n', toc); \ No newline at end of file