diff --git a/unitTests/TestSimulator.m b/unitTests/TestSimulator.m index 5a628e0e49e042c99c0ea9245938fbc903ea9871..50985ee4434ca41066029f593048af31e5f94cf2 100644 --- a/unitTests/TestSimulator.m +++ b/unitTests/TestSimulator.m @@ -1,10 +1,7 @@ classdef TestSimulator < UnitTest - % TEST FUNZIONANTE, DA RISOLVERE PATH PER simulatorConfig.m in saveTest - % MANCA refSolid - properties - SimulatorSettings Settings % [-] + simulatorSettings Settings refSimulator end @@ -14,13 +11,11 @@ classdef TestSimulator < UnitTest methods - function saveTest(testCase, testName, mission) + function saveTest(~, testName, mission) Time = tic; disp('Started saving simulator tests') - mainSimPath = fullfile('..', '..', 'simulator'); - addpath(genpath(mainSimPath)); currentPath = fileparts(mfilename('fullpath')); addpath(genpath(currentPath)); @@ -29,7 +24,7 @@ classdef TestSimulator < UnitTest wind = WindCustom(mission); mainSimPath = fullfile('..', 'simulator', 'simulatorConfig.m'); mainOdePath = fullfile('..', 'common', 'settings', 'odeConfig.m'); - SimulatorSettings = Settings(mainSimPath, mainOdePath); + SimulatorSettings = Settings(mainSimPath, mainOdePath); %#ok<*PROPLC> SimulatorSettings.simulator.SMonly = 0; if strcmp(testName, 'ballistic') SimulatorSettings.simulator.ballistic = 1; @@ -75,7 +70,7 @@ classdef TestSimulator < UnitTest % fieldName = ['referenceState_' verifiable]; testCase.refSimulator = load(filePath, 'stateA', 'stateF'); - testCase.SimulatorSettings = load(filePath, 'SimulatorSettings').SimulatorSettings; + testCase.simulatorSettings = load(filePath, 'SimulatorSettings').SimulatorSettings; % Construct the file path dynamically based on the test parameter @@ -86,13 +81,13 @@ classdef TestSimulator < UnitTest methods (Test) function mainSimulatorTest(testCase, verifiable) - testCase.createTest(verifiable); + testCase.createTestSimulator(verifiable); mainSimPath = fullfile('..', 'simulator'); addpath(genpath(mainSimPath)); % Run main simulator - [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.SimulatorSettings); + [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings); postp.stateA = postp.stateA(end, :); postp.stateF = postp.stateF(end, :); diff --git a/unitTests/configUnitTest.m b/unitTests/configUnitTest.m index 4360727fa2a4ba42ffca725cfde0525f119b8e4c..5851157d891ba5bcae6bad4939015162e9efa44a 100644 --- a/unitTests/configUnitTest.m +++ b/unitTests/configUnitTest.m @@ -1,7 +1,7 @@ % config unit-test % choose the mission -mission = Mission("2024_Lyra_Portugal_October"); +mission = Mission("2025_Orion_Portugal_October"); %% UNIT TESTS TO RUN % choose which folders to test diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat index 9255c4f66ee7bbcbbe47857e2252751643986fa8..8cfc399f05c2c3dbefd7c133362c86a7cddcba7c 100644 --- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat +++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2696a5102cf8171d2aa2f889a95ce9c5fdfac502d865acf5be43db919fd6c200 -size 51442799 +oid sha256:6b06e877dfda0149f4c9d53923e00b26c8564dcb427fe7f4978cd46ec8b68d12 +size 51436842 diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat index 15af0520edcca8a2f4ad59625997aea0fe6a2bba..9543c5857ef537d7d777bcdc434b7e7e78b79533 100644 --- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat +++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b82a489c282a3fcf30b5e4ff78fe07216c4e1ed4bcb24b84ffb8ddf7a8f0b7f8 -size 51073079 +oid sha256:946f4c8524c558b73f4d6a53fb920977215b32c220f543137d7a2d4e64c26a14 +size 50932249 diff --git a/unitTests/tests/apogeeUnitTests.m b/unitTests/tests/apogeeUnitTests.m deleted file mode 100644 index 678ed54488f2dcf21d9400856f2ef1ea51a4f928..0000000000000000000000000000000000000000 --- a/unitTests/tests/apogeeUnitTests.m +++ /dev/null @@ -1,114 +0,0 @@ -%{ -apogeeUnitTest - this script is the apogee analysis unit test - -CALLED SCRIPTS: - -CALLED FUNCTIONS: - -CALLED DATA FILES: /data - -NOTES: in order to run this script as a test, it has to be called by -'runtests' funciton. (ex.: results = runtests('apogeeUnitTests')). If you want to -run it as a simple script, it's advised to active 'pause on errors'. - -REVISIONS: -- 0 31/03/2023, release Matteo Gotti -- 1 02/04/2023, update Riccardo Cadamuro - less cases to be tested, different phases added - -Copyright © 2021, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later - -%} - -% tolerance -toll.absToll = 0.001; -toll.relToll = 0.001; - -errorMsg = 'Results errors are exceeding tolerance'; - -addpath(genpath('../../commonFunctions')) -addpath(genpath('../../apogeeAnalysis')) - -%% StandardApogeeSolid -run('../data/testApogeeAnalysis/standardApogee/configSLD.m'); -load('../data/testApogeeAnalysis/standardApogee/referenceSOLID.mat'); -load('../data/testApogeeAnalysis/standardApogee/dataSOLID.mat'); -settings.motors = dataSOLID.motors; -resTest = standardApogee(settings, dataSOLID.vars); - - -checkMS = checkErrorMSA(dataSOLID.ms, resTest.ms, toll); -if not(checkMS) - errorMsg = strcat(errorMsg, ' [ms] '); -end - -checkAPO = checkErrorMSA(refSOLID.apogee, resTest.apogee, toll); -if not(checkAPO) - errorMsg = strcat(errorMsg, ' [Apogee] '); -end - -checkVEL = checkErrorMSA(refSOLID.vExit, resTest.vExit, toll); -if not(checkVEL) - errorMsg = strcat(errorMsg, ' [vExit] '); -end - -checkACC = checkErrorMSA(refSOLID.maxAcc, resTest.max_a, toll); -if not(checkACC) - errorMsg = strcat(errorMsg, ' [max_acc] '); -end -check = checkACC&&checkVEL&&checkACC&&checkMS; -assert(check, errorMsg) - -%% StandardApogeeHybrid -run('../data/testApogeeAnalysis/standardApogee/configHYB.m'); -load('../data/testApogeeAnalysis/standardApogee/referenceHYB.mat'); -load('../data/testApogeeAnalysis/standardApogee/dataHYB.mat'); -settings.motors = dataHYB.motors; -resTest = standardApogee(settings, dataHYB.vars); - -checkMS = checkErrorMSA(dataHYB.ms, resTest.ms, toll); -if not(checkMS) - errorMsg = strcat(errorMsg, ' [ms] '); -end - -checkAPO = checkErrorMSA(refHYB.apogee, resTest.apogee, toll); -if not(checkAPO) - errorMsg = strcat(errorMsg, ' [Apogee] '); -end - -checkVEL = checkErrorMSA(refHYB.vExit, resTest.vExit, toll); -if not(checkVEL) - errorMsg = strcat(errorMsg, ' [vExit] '); -end - -checkACC = checkErrorMSA(refHYB.maxAcc, resTest.max_a, toll); -if not(checkACC) - errorMsg = strcat(errorMsg, ' [max_acc] '); -end - -check = checkACC&&checkVEL&&checkACC&&checkMS; -assert(check, errorMsg) - -%% engineCutApogeeAnalysis -run('../data/testApogeeAnalysis/engineCutApogee/config.m'); -load('../data/testApogeeAnalysis/engineCutApogee/dataEC.mat'); -load('../data/testApogeeAnalysis/engineCutApogee/referenceEC.mat'); - -settings.motors = dataEC.motors; -resTest = engineCutApogee(settings, dataEC.vars); - -checkTCO = checkErrorMSA(refEC.tCO, resTest.tCO, toll); -if not(checkTCO) - errorMsg = strcat(errorMsg, ' [cutoff time] '); -end - -checkAPO = checkErrorMSA(refEC.apogee, resTest.apogee, toll); -if not(checkAPO) - errorMsg = strcat(errorMsg, ' [Apogee] '); -end - -check = checkAPO&&checkTCO; -assert(check, errorMsg); diff --git a/unitTests/tests/artifacts/results.xml b/unitTests/tests/artifacts/results.xml deleted file mode 100644 index 331354a0d19291893e8ac54b0733f0f10e537297..0000000000000000000000000000000000000000 --- a/unitTests/tests/artifacts/results.xml +++ /dev/null @@ -1,181 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no" ?> -<testsuites> - <testsuite errors="8" failures="0" name="simulatorUnitTests" skipped="0" tests="10" time="13.0302"> - <testcase classname="simulatorUnitTests" name="StandardSolid" time="3.8148"> - <error>Error occurred in simulatorUnitTests/StandardSolid and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "para". - - Error in descentParachute (line 51) - para = settings.stoch.para; - - Error in odearguments (line 92) - f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0. - - Error in ode113 (line 116) - odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin); - - Error in stdRun (line 225) - [Tp, Yp] = ode113(@descentParachute, [t0p, tf], Y0p, settings.ode.optionspara, settings); - - Error in simulatorUnitTests (line 39) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="StandardHRE_Arb1" time="1.4489"> - <error>Error occurred in simulatorUnitTests/StandardHRE_Arb1 and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 58) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="StandardHRE_Arb2" time="1.2899"> - <error>Error occurred in simulatorUnitTests/StandardHRE_Arb2 and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 76) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="StandardHRE_Arb3" time="1.4571"> - <error>Error occurred in simulatorUnitTests/StandardHRE_Arb3 and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 94) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="test6DOF" time="1.3205"> - <error>Error occurred in simulatorUnitTests/test6DOF and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 112) - [~, stateToTestF] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="ballistic" time="0.85344"> - <error>Error occurred in simulatorUnitTests/ballistic and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRunBal (line 69) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 126) - [~, stateToTestF] = stdRunBal(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="multipleAB" time="0.90323"> - <error>Error occurred in simulatorUnitTests/multipleAB and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 140) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="engineCutSimulator" time="1.8463"> - <error>Error occurred in simulatorUnitTests/engineCutSimulator and it did not run to completion. - --------- - Error ID: - --------- - 'MATLAB:nonExistentField' - -------------- - Error Details: - -------------- - Unrecognized field name - "altitudes". - - Error in setWindData (line 3) - s = length(wind.altitudes); - - Error in stdRun (line 86) - settings.wind = setWindData(settings.wind); - - Error in simulatorUnitTests (line 158) - [~, stateToTestF, ~, stateToTestA] = stdRun(settings);</error> - </testcase> - <testcase classname="simulatorUnitTests" name="WindInputGenerator" time="0.04655"/> - <testcase classname="simulatorUnitTests" name="WindVariableGenerator" time="0.04959"/> - </testsuite> -</testsuites> diff --git a/unitTests/tests/checkErrorMSA.m b/unitTests/tests/checkErrorMSA.m deleted file mode 100644 index ef55400d0e8060e4ff1e264a8115685101a784d1..0000000000000000000000000000000000000000 --- a/unitTests/tests/checkErrorMSA.m +++ /dev/null @@ -1,46 +0,0 @@ -function check = checkErrorMSA(reference, test, toll) -%{ -checkErrorMSA - checks that at least one between the relative and absolute -error between each elemente of the test and reference array is under the given tolerace - -INPUT: - reference, double [m,k]: reference data - test , double [m,k]: data to be tested - toll , struct : contains relToll and absToll to be considered - -OUTPUT: - check: TRUE at least one between the absolute and relative error for each element is - under the prescribed tolerance, FALSE otherways. - -REVISIONS: -- 0 29/03/2023, release Riccardo Cadamuro - -Copyright © 2023, Skyward Experimental Rocketry, AFD department -All rights reserved - -%} - if numel(reference) ~= numel(test) - error('Refence array and test array shall contain the same number of elements'); - end - - reference = reshape(reference, [1, numel(reference)]); - test = reshape(test, [1, numel(test)]); - - relToll = toll.relToll; - absToll = toll.absToll; - - absErr = abs(reference - test); - relErr = absErr./reference; - - % avoid nan in error computation - indexZero = (reference == 0); - relErr(indexZero) = absErr(indexZero); - - absCheck = absErr < absToll; - relCheck = relErr < relToll; - - check = true; - if any(sum([absCheck; relCheck]) == 0) - check = false; - end -end \ No newline at end of file diff --git a/unitTests/tests/cmnFnctnUnitTests.m b/unitTests/tests/cmnFnctnUnitTests.m deleted file mode 100644 index 494e6a1b12510e48aad42e323ff487e91884225f..0000000000000000000000000000000000000000 --- a/unitTests/tests/cmnFnctnUnitTests.m +++ /dev/null @@ -1,51 +0,0 @@ -%{ -cmnFnctnUnitTests - this script is the common functions unit test - -CALLED SCRIPTS: - -CALLED FUNCTIONS: - -CALLED DATA FILES: /data - -NOTES: in order to run this script as a test, it has to be called by -'runtests' funciton. (ex.: results = runtests('cmnFnctnUnitTests')). If you want to -run it as a simple script, it's advised to active 'pause on errors'. - -REVISIONS: -- 0 16/03/2023, release Simone Cimolato - -Copyright © 2021, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later - -%} - -errorMsg = 'Results errors are exceeding tolerance'; -addpath(genpath('../../commonFunctions')) - -%% InterpCoeffs -% config -run('../data/testCommonFunctions/interpCoeffs/config.m'); - -% reference -load('../data/testCommonFunctions/interpCoeffs/coeffsValue.mat'); -load('../data/testCommonFunctions/interpCoeffs/angles.mat'); - -% interpCoeffs -[testCoeffsValue, testAngles] = interpCoeffs(t, alpha, M, beta, alt, c, settings); -check = isequal(testCoeffsValue, referenceCoeffsValue) && isequal(testAngles, referenceAngles); -assert(check, errorMsg) - -%% CreateDissileInput -% config -run('../data/testCommonFunctions/createDissileInput/config.m'); - -% reference -load('../data/testCommonFunctions/createDissileInput/referenceInputValue.mat'); - -% createDissileInput -[testInput] = createDissileInput(settings, vars); - -check = isequal(testInput, referenceInput); -assert(check, errorMsg) diff --git a/unitTests/tests/optUnitTests.m b/unitTests/tests/optUnitTests.m deleted file mode 100644 index e966ad35f41632fddc08abddcc2fed8e870e1da2..0000000000000000000000000000000000000000 --- a/unitTests/tests/optUnitTests.m +++ /dev/null @@ -1,93 +0,0 @@ -%{ -optUnitTest - this script is the aerodynamicOptimization unit test - -CALLED SCRIPTS: - -CALLED FUNCTIONS: - -CALLED DATA FILES: /data - -NOTES: in order to run this script as a test, it has to be called by -'runtests' funciton. (ex.: results = runtests('optUnitTest')). If you want to -run it as a simple script, it's advised to active 'pause on errors'. - -REVISIONS: -- 0 16/03/2023, release Simone Cimolato - -Copyright © 2021, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later - -%} - -% reference -load('../data/testOptimization/singleGARun/refOptGA.mat'); - -% tolerance -absErr = 1e-6; - -errorMsg = 'Results errors are exceeding tolerance'; -errorMsgSM = 'Error in "XCPcheck"'; -errorMsgApo = 'Error in "optimizationGA"'; - -addpath(genpath('../../../dissileMatcom')) -addpath(genpath('../../aerodynamicsOptimization')) -addpath(genpath('../../commonFunctions')) - -%% BoatTailTrueModHaackTrue -% config -run('../data/testOptimization/singleGARun/config1.m'); - -% singleGaRun -[~, ~, testSingleGA1, testSingleGA2] = singleGArun(lb, ub, input, settings); - -check1 = ~(abs(ref.ApoBoatModH - testSingleGA1) >= absErr); -check2 = abs(testSingleGA2 - ref.CBoatModH)<absErr; - -assert(or(check1,check2), errorMsg) -assert(check1,errorMsgApo) -assert(check2,errorMsgSM) - -%% BoatTailFalseModHaackTrue -% config -run('../data/testOptimization/singleGARun/config2.m'); - -% singleGaRun -[~, ~, testSingleGA1, testSingleGA2] = singleGArun(lb, ub, input, settings); - -check1 = ~(abs(ref.ApoModHOnly - testSingleGA1) >= absErr); -check2 = abs(testSingleGA2 - ref.CModHOnly)<absErr; - -assert(or(check1,check2), errorMsg) -assert(check1,errorMsgApo) -assert(check2,errorMsgSM) - -%% BoatTailFalseModHaackFalse -% config -run('../data/testOptimization/singleGARun/config3.m'); - -% singleGaRun -[~, ~, testSingleGA1, testSingleGA2] = singleGArun(lb, ub, input, settings); - -check1 = ~(abs(ref.ApoNoBoatNoModH - testSingleGA1) >= absErr); -check2 = abs(testSingleGA2 - ref.CNoBoatNoModH)<absErr; - -assert(or(check1,check2), errorMsg) -assert(check1,errorMsgApo) -assert(check2,errorMsgSM) - -%% BoatTailTrueModHaackFalse -% config -run('../data/testOptimization/singleGARun/config4.m'); - -% singleGaRun -[~, ~, testSingleGA1, testSingleGA2] = singleGArun(lb, ub, input, settings); - -check1 = ~(abs(ref.ApoBoatOnly - testSingleGA1) >= absErr); -check2 = abs(testSingleGA2 - ref.CBoatOnly)<absErr; - -assert(or(check1,check2), errorMsg) -assert(check1,errorMsgApo) -assert(check2,errorMsgSM) - diff --git a/unitTests/tests/runTest.m b/unitTests/tests/runTest.m deleted file mode 100644 index f241a4513b96181e19e3a93d7983ac1352b46eb4..0000000000000000000000000000000000000000 --- a/unitTests/tests/runTest.m +++ /dev/null @@ -1,18 +0,0 @@ -% runTests - -% import -import matlab.unittest.TestRunner -import matlab.unittest.Verbosity -import matlab.unittest.plugins.XMLPlugin - -% -% tests = {'optUnitTests.m','apogeeUnitTests.m','cmnfnctnUnitTests.m',... -% 'sensitivityUnitTests.m','simulatorUnitTests.m'}; -tests = {'simulatorUnitTests.m'}; -suite = testsuite(tests); -[~,~] = mkdir('artifacts'); -runner = TestRunner.withTextOutput('OutputDetail',Verbosity.Detailed); -runner.addPlugin(XMLPlugin.producingJUnitFormat('artifacts/results.xml')) - -results = runner.run(suite); -assertSuccess(results); diff --git a/unitTests/tests/sensitivityUnitTests.m b/unitTests/tests/sensitivityUnitTests.m deleted file mode 100644 index a53b83fec0adeff373e841448fd4374be344f679..0000000000000000000000000000000000000000 --- a/unitTests/tests/sensitivityUnitTests.m +++ /dev/null @@ -1,55 +0,0 @@ -%{ -sensitivityUnitTest - this script is the sensitivityAnalysis unit test - -CALLED SCRIPTS: - -CALLED FUNCTIONS: - -CALLED DATA FILES: /data - -NOTES: in order to run this script as a test, it has to be called by -'runtests' funciton. (ex.: results = runtests('simulatorUnitTests')). If you want to -run it as a simple script, it's advised to active 'pause on errors'. - -REVISIONS: -- 0 29/03/2023, release Riccardo Cadamuro - -Copyright © 2023, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later -%} - -% tolerance -toll.absToll = 0.001; -toll.relToll = 0.001; - -errorMsg = 'Results errors are exceeding tolerance'; - -addpath(genpath('../../commonFunctions')) -addpath(genpath('../../sensitivityAnalysis')) - -run('../data/testSensitivityAnalysis/config.m'); - -% loading test data -load('../data/testSensitivityAnalysis/referenceSensitivity.mat'); - -%% createParameterTest -check = isequal(referenceSensitivity.parameters, parameters); -assert(check, errorMsg); - -%% sensitivityApogeeLoopTest -windMat = referenceSensitivity.windMat; -modFactor = referenceSensitivity.modFactor; -finalStateReference = referenceSensitivity.Yend; - -finalStateTest = zeros(size(finalStateReference)); -for i = 1:settings.stoch.N - [settingsM, Q0] = updateSettings(settings, parameters, modFactor(i, :), windMat(i, [7 8 11 9 10 12]) ); - Y0 = [0; 0; 0; 0; 0; 0; 0; 0; 0; Q0]; - data = stochAscentLoop(settingsM, Y0); - finalStateTest(i, :) = data.state.Y(end, :); -end - -check = checkErrorMSA(finalStateReference, finalStateTest, toll); -assert(check, errorMsg); \ No newline at end of file diff --git a/unitTests/tests/simulatorUnitTests.m b/unitTests/tests/simulatorUnitTests.m deleted file mode 100644 index 820156d8077758fed1245de38d5ab67389dbf85e..0000000000000000000000000000000000000000 --- a/unitTests/tests/simulatorUnitTests.m +++ /dev/null @@ -1,210 +0,0 @@ -%{ -simulatorUnitTest - this script is the simulator unit test - -CALLED SCRIPTS: - -CALLED FUNCTIONS: - -CALLED DATA FILES: /data - -NOTES: in order to run this script as a test, it has to be called by -'runtests' funciton. (ex.: results = runtests('simulatorUnitTests')). If you want to -run it as a simple script, it's advised to active 'pause on errors'. - -REVISIONS: -- 0 16/03/2023, release Simone Cimolato -Copyright © 2021, Skyward Experimental Rocketry, AFD department -All rights reserved - -SPDX-License-Identifier: GPL-3.0-or-later - -%} - -% tolerance -toll.absToll = 0.001; -toll.relToll = 0.001; - -addpath(genpath('../../commonFunctions')) -addpath(genpath('../../simulator')) - -errorMsg = 'Results errors are exceeding tolerance'; - -%% StandardSolid -run('../data/testSimulator/standard_solid/config.m'); - -% loading test data -referenceState = load('../data/testSimulator/standard_solid/referenceState_std_solid.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_std_solid, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_std_solid, stateToTest.F, toll); -check = checkF && checkA; - -assert(check, errorMsg) - -%% StandardHRE - arb 1 -run('../data/testSimulator/standard_HRE/config1.m'); - -% loading test data -referenceState = load('../data/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_std_HRE, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_std_HRE, stateToTest.F, toll); -check = checkA && checkF; -assert(check, errorMsg) - -%% StandardHRE - arb 2 -run('../data/testSimulator/standard_HRE/config2.m'); - -% loading test data -referenceState = load('../data/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_std_HRE, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_std_HRE, stateToTest.F, toll); -check = checkA && checkF; -assert(check, errorMsg) - -%% StandardHRE - arb 3 -run('../data/testSimulator/standard_HRE/config3.m'); - -% loading test data -referenceState = load('../data/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_std_HRE, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_std_HRE, stateToTest.F, toll); -check = checkA && checkF; -assert(check, errorMsg) - -%% 6 DOF -run('../data/testSimulator/6DOF/config.m'); - -% loading test data -referenceState = load('../data/testSimulator/6DOF/referenceState6DOF.mat'); - -% simulator -[~, stateToTestF] = stdRun(settings); - -stateToTest.F = stateToTestF(end, :); % final state, at touchdown - -check = checkErrorMSA(referenceState.stateF6DOF, stateToTest.F, toll); -assert(check, errorMsg) - -%% ballistic -run('../data/testSimulator/ballistic/config.m'); - -% loading test data -referenceState = load('../data/testSimulator/ballistic/referenceStateBallistic.mat'); - -% simulator -[~, stateToTestF] = stdRunBal(settings); - -stateToTest.F = stateToTestF(end, :); % final state, at touchdown - -check = checkErrorMSA(referenceState.stateFBallistic, stateToTest.F, toll); -assert(check, errorMsg) - -%% multiple AB -run('../data/testSimulator/multiple_AB/config.m'); - -% loading test data -referenceState = load('../data/testSimulator/multiple_AB/referenceState_multipleAB.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_multipleAB, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_multipleAB, stateToTest.F, toll); -check = checkF && checkA; -assert(check, errorMsg) - -%% engineCutSimulator -run('../data/testSimulator/engineCut/config.m'); - -% loading test data -referenceState = load('../data/testSimulator/engineCut/referenceState_engineCut.mat'); - -% simulator -[~, stateToTestF, ~, stateToTestA] = stdRun(settings); - -stateToTest.A = stateToTestA(end, :); % state at end of ascent -stateToTest.F = stateToTestF(end, :); % final state, at touchdown -stateToTest.F = [stateToTest.F zeros(1, 7)]; % to avoid problems later in checkErrorSimulator - -checkA = checkErrorMSA(referenceState.stateA_engineCut, stateToTest.A, toll); -checkF = checkErrorMSA(referenceState.stateF_engineCut, stateToTest.F, toll); -check = checkF && checkA; -assert(check, errorMsg) - -%%% WIND MODELS - -%% WindInputGenerator -settings.wind.inputGround = 6; -settings.wind.inputAlt = linspace(0, 4000, 100); % altitude vector [m] -settings.wind.inputMagnitude = [6 * ones(1, 12), 12 * ones(1, 50), 20 * ones(1,38)]; -settings.wind.inputAzimut = 180 * ones(1, 100); % wind azimut angle at each altitude (toward wind incoming direction) [deg] -settings.wind.inputMult = (settings.wind.inputMagnitude./settings.wind.inputGround - 1) * 100; -inputUncertainty = [50, 180]; -z = 200; - -% loading test data -referenceState = load('../data/testSimulator/windModels/referenceWindInputComponents.mat'); - -% wind generation -[StateToTest.uw, StateToTest.vw, StateToTest.ww] = windInputGenerator(settings, z, inputUncertainty); - -check1 = isequal(StateToTest.uw, referenceState.uwInput); -check2 = isequal(StateToTest.vw, referenceState.vwInput); -check3 = isequal(StateToTest.ww, referenceState.wwInput); -check = check1 && check2 && check3; -assert(check, errorMsg) - -%% WindVariableGenerator -wind.magG = 4.7; -wind.azG = 75*pi/180; -wind.hG = 100; -wind.magH = 13; -wind.hH = 1000; -z = 200; - -% loading test data -referenceState = load('../data/testSimulator/windModels/referenceWindVariableComponents.mat'); - -% wind generation -[StateToTest.uw, StateToTest.vw, StateToTest.ww] = windVariableGenerator(z, wind); - -check1 = isequal(StateToTest.uw, referenceState.uwVariable); -check2 = isequal(StateToTest.vw, referenceState.vwVariable); -check3 = isequal(StateToTest.ww, referenceState.wwVariable); -check = check1 && check2 && check3; -assert(check, errorMsg)