From fe07c051d30f04de9c23f43130e31cd70ffa7df2 Mon Sep 17 00:00:00 2001
From: LolloBici <lorenzo.amici@skywarder.eu>
Date: Fri, 22 Nov 2024 14:08:05 +0100
Subject: [PATCH] [unit-test][unitTests]Updated unitTests, the only remaining
 bugs are related to the sensitivity and apogee tools.

---
 sensitivityAnalysis/mainSensitivity.m         |   2 +-
 unitTests/README.md                           |  65 +++++-
 unitTests/TestSimulator.m                     |  98 --------
 unitTests/configUnitTest.m                    |   8 +-
 .../engineCutApogee/refEngineCut.mat          |   4 +-
 .../standardApogee/refStandard.mat            |   4 +-
 .../createDissileInput/refInput.mat           |   3 +
 .../interpCoeffs/refInterpCoeffs.mat          |   3 +
 .../testCommonFunctions/refInterpCoeffs.mat   |   3 +
 .../refSensitivity.mat                        |   4 +-
 .../testSimulator/HRE/referenceState_HRE.mat  |   4 +-
 .../ballistic/referenceState_ballistic.mat    |   4 +-
 .../engineCut/referenceState_engineCut.mat    |   4 +-
 .../multipleAB/referenceState_multipleAB.mat  |   4 +-
 .../solid/referenceState_solid.mat            |   3 +
 unitTests/mainUnitTest.m                      |   2 +-
 unitTests/saveTests.m                         |  13 +-
 unitTests/{ => tests}/TestApogeeAnalysis.m    |  20 +-
 unitTests/{ => tests}/TestCommonFunctions.m   |  50 +++--
 unitTests/{ => tests}/TestSensitivity.m       |  21 +-
 unitTests/tests/TestSimulator.m               | 111 +++++++++
 unitTests/{ => tests}/UnitTest.m              |   0
 unitTests/unitTestsOld/README.md              |  12 +
 .../artifacts/results.xml                     |   0
 .../configUnitTestsOld.m}                     |   0
 .../createTestsOld.m}                         |   0
 .../dataOld/HRE_FURIA-EUROC-T04T03.mat        |   0
 .../dataOld/SRM_M1520-BS.mat                  |   0
 .../dataOld/geminiData.m                      |   0
 .../dataOld/pyxisData.m                       |   0
 .../engineCutApogee/config.m                  |   0
 .../engineCutApogee/dataEC.mat                |   0
 .../engineCutApogee/referenceEC.mat           |   0
 .../engineCutApogee/referenceEngineCut.mat    |   0
 .../standardApogee/configHYB.m                |   0
 .../standardApogee/configSLD.m                |   0
 .../standardApogee/dataHYB.mat                |   0
 .../standardApogee/dataSOLID.mat              |   0
 .../standardApogee/referenceHYB.mat           |   0
 .../standardApogee/referenceSOLID.mat         |   0
 .../standardApogee/referenceStandard.mat      |   0
 .../createDissileInput/config.m               |   0
 .../referenceInputValue.mat                   |   0
 .../interpCoeffs/angles.mat                   |   0
 .../interpCoeffs/coeffsValue.mat              |   0
 .../testCommonFunctions/interpCoeffs/config.m |   0
 .../testOptimization/singleGARun/config1.m    |   0
 .../testOptimization/singleGARun/config2.m    |   0
 .../testOptimization/singleGARun/config3.m    |   0
 .../testOptimization/singleGARun/config4.m    |   0
 .../testOptimization/singleGARun/refOptGA.mat |   0
 .../dataOld/testSensitivityAnalysis/config.m  |   0
 .../referenceSensitivity.mat                  |   0
 .../dataOld/testSimulator/6DOF/config.m       |   0
 .../testSimulator/6DOF/referenceState6DOF.mat |   0
 .../dataOld/testSimulator/ballistic/config.m  |   0
 .../ballistic/referenceStateBallistic.mat     |   0
 .../dataOld/testSimulator/engineCut/config.m  |   0
 .../testSimulator/multiple_AB/config.m        |   0
 .../multiple_AB/referenceState_multipleAB.mat |   0
 .../testSimulator/standard_HRE/config1.m      |   0
 .../testSimulator/standard_HRE/config2.m      |   0
 .../testSimulator/standard_HRE/config3.m      |   0
 .../referenceState_std_HRE_ARB1.mat           |   0
 .../referenceState_std_HRE_ARB2.mat           |   0
 .../referenceState_std_HRE_ARB3.mat           |   0
 .../testSimulator/standard_solid/config.m     |   0
 .../referenceState_std_solid.mat              |   0
 .../referenceWindInputComponents.mat          |   0
 .../referenceWindVariableComponents.mat       |   0
 .../windModels/windInputComponents.mat        |   0
 .../windModels/windVariableComponents.mat     |   0
 .../mainUnitTestsOld.m}                       |   0
 .../src/apogeeCreateTests.m                   |   0
 .../src/cmnFnctnCreateTests.m                 |   0
 .../src/optCreateTests.m                      |   0
 .../src/sensitivityCreateTests.m              |   0
 .../src/simulatorCreateTests.m                |   0
 .../unitTestsOld/testsOld/apogeeUnitTests.m   | 114 ++++++++++
 .../testsOld/artifacts/results.xml            | 181 +++++++++++++++
 .../unitTestsOld/testsOld/checkErrorMSA.m     |  46 ++++
 .../unitTestsOld/testsOld/cmnFnctnUnitTests.m |  51 +++++
 .../unitTestsOld/testsOld/optUnitTests.m      |  93 ++++++++
 unitTests/unitTestsOld/testsOld/runTest.m     |  18 ++
 .../testsOld/sensitivityUnitTests.m           |  55 +++++
 .../testsOld/simulatorUnitTests.m             | 210 ++++++++++++++++++
 86 files changed, 1044 insertions(+), 166 deletions(-)
 delete mode 100644 unitTests/TestSimulator.m
 create mode 100644 unitTests/data/testCommonFunctions/createDissileInput/refInput.mat
 create mode 100644 unitTests/data/testCommonFunctions/interpCoeffs/refInterpCoeffs.mat
 create mode 100644 unitTests/data/testCommonFunctions/refInterpCoeffs.mat
 create mode 100644 unitTests/data/testSimulator/solid/referenceState_solid.mat
 rename unitTests/{ => tests}/TestApogeeAnalysis.m (56%)
 rename unitTests/{ => tests}/TestCommonFunctions.m (56%)
 rename unitTests/{ => tests}/TestSensitivity.m (74%)
 create mode 100644 unitTests/tests/TestSimulator.m
 rename unitTests/{ => tests}/UnitTest.m (100%)
 create mode 100644 unitTests/unitTestsOld/README.md
 rename unitTests/{unitTestOld => unitTestsOld}/artifacts/results.xml (100%)
 rename unitTests/{unitTestOld/configUnitTests.m => unitTestsOld/configUnitTestsOld.m} (100%)
 rename unitTests/{unitTestOld/createTests.m => unitTestsOld/createTestsOld.m} (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/HRE_FURIA-EUROC-T04T03.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/SRM_M1520-BS.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/geminiData.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/pyxisData.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/engineCutApogee/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/engineCutApogee/dataEC.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/engineCutApogee/referenceEC.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/engineCutApogee/referenceEngineCut.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/configHYB.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/configSLD.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/dataHYB.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/dataSOLID.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/referenceHYB.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/referenceSOLID.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testApogeeAnalysis/standardApogee/referenceStandard.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testCommonFunctions/createDissileInput/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testCommonFunctions/createDissileInput/referenceInputValue.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testCommonFunctions/interpCoeffs/angles.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testCommonFunctions/interpCoeffs/coeffsValue.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testCommonFunctions/interpCoeffs/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testOptimization/singleGARun/config1.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testOptimization/singleGARun/config2.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testOptimization/singleGARun/config3.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testOptimization/singleGARun/config4.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testOptimization/singleGARun/refOptGA.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSensitivityAnalysis/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSensitivityAnalysis/referenceSensitivity.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/6DOF/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/6DOF/referenceState6DOF.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/ballistic/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/ballistic/referenceStateBallistic.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/engineCut/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/multiple_AB/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/multiple_AB/referenceState_multipleAB.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/config1.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/config2.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/config3.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_solid/config.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/standard_solid/referenceState_std_solid.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/windModels/referenceWindInputComponents.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/windModels/referenceWindVariableComponents.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/windModels/windInputComponents.mat (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/dataOld/testSimulator/windModels/windVariableComponents.mat (100%)
 rename unitTests/{unitTestOld/mainUnitTests.m => unitTestsOld/mainUnitTestsOld.m} (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/src/apogeeCreateTests.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/src/cmnFnctnCreateTests.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/src/optCreateTests.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/src/sensitivityCreateTests.m (100%)
 rename unitTests/{unitTestOld => unitTestsOld}/src/simulatorCreateTests.m (100%)
 create mode 100644 unitTests/unitTestsOld/testsOld/apogeeUnitTests.m
 create mode 100644 unitTests/unitTestsOld/testsOld/artifacts/results.xml
 create mode 100644 unitTests/unitTestsOld/testsOld/checkErrorMSA.m
 create mode 100644 unitTests/unitTestsOld/testsOld/cmnFnctnUnitTests.m
 create mode 100644 unitTests/unitTestsOld/testsOld/optUnitTests.m
 create mode 100644 unitTests/unitTestsOld/testsOld/runTest.m
 create mode 100644 unitTests/unitTestsOld/testsOld/sensitivityUnitTests.m
 create mode 100644 unitTests/unitTestsOld/testsOld/simulatorUnitTests.m

diff --git a/sensitivityAnalysis/mainSensitivity.m b/sensitivityAnalysis/mainSensitivity.m
index 741886d9..eee5d0ba 100644
--- a/sensitivityAnalysis/mainSensitivity.m
+++ b/sensitivityAnalysis/mainSensitivity.m
@@ -72,7 +72,7 @@ end
 %   4-both ballistic and parachute descent
 %   5-stability
 
-settings.addprop('simulator');
+if ~isprop(settings, 'simulator'), settings.addprop('simulator'); end
 settings.simulator.ascent = true;
 settings.simulator.ballistic = false;
 settings.simulator.parachute = false;
diff --git a/unitTests/README.md b/unitTests/README.md
index 3593b687..1f359d44 100644
--- a/unitTests/README.md
+++ b/unitTests/README.md
@@ -1,12 +1,61 @@
-# unitTests
-This folder contains all the scripts to create and perform unit tests on the toolkit, using data that is known to be correct.
+# Unit Testing Framework for msa-toolkit
 
-## Usage
-You can use <code>createTests.m</code> to create new reference data for the tests if you are sure that the toolkit works properly.
+This repository provides a unit testing framework designed to validate key functionalities for some tools of the msa-toolkit.
+It includes various test classes, scripts for configuration and execution, and a `data` folder containing reference data and inputs for the tests.
 
-To run the tests you have to set the config in <code>configUnitTests.m</code> and then run <code>mainUnitTests.m</code>.
+---
 
-However, you have to set the absolute and relative tolerance for each test in each script (e.g. <code>src/simulatorUnitTests.m</code>).
+## **Folder Structure**
 
-## Output
-The program displays in the command window wheter the toolkit has passed each particular test or not.
\ No newline at end of file
+### **Key Components**
+- **`data/`**: Stores all reference data and input files needed for the tests.
+- **Test Classes**: Each class (e.g., `TestCommonFunctions`, `TestSimulator`).
+- **Scripts**:
+  - **`mainUnitTest.m`**: Executes the selected tests based on the configuration.
+  - **`saveTests.m`**: Saves settings and reference data for future tests.
+  - **`configUnitTest.m`**: Allows users to configure which tests to run or save, as well as the mission parameters.
+
+---
+
+## **How to Run Tests**
+
+### 1. **Automatic Testing**
+Tests are executed automatically when merging a branch into the `main` branch.
+This ensures all functionalities are validated before the merge.
+
+### 2. **Manual Testing**
+To run tests manually:
+1. **Configure Tests**: Open the `configUnitTest.m` script and specify:
+   - The tests to be executed.
+   - The mission parameters for the tests.
+2. **Run the Tests**: Execute the `mainUnitTest.m` script:
+
+---
+
+## **How to Save Tests**
+
+### 2. **Manual Testing**
+1. **Configure Tests**: Open the `configUnitTest.m` script and specify:
+   - The tests to be saved.
+   - The mission parameters for the tests.
+2. **Save the Tests**: Execute the `saveTests.m` script:
+   - For `TestSimulator`, you need to add a verifiable string (e.g. `verifiable = 'HRE'`).
+   - For `TestCommonFunction`, it is necessary to define several key variables
+     that are essential for the test setup. These variables include `vars`, `t`,
+     `alpha`, `mach`, `beta`, `alt` and `c`
+     (e.g.  
+```
+vars.mach = 0.05:0.05:1;
+            vars.alpha = [-10 -7.5 -5 -2.5 -1 -0.5 -0.1 0 0.1 0.5 1 2.5 5 7.5 10];
+            vars.beta = [-2.5 -0.1 0 0.1 2.5];
+            vars.alt = (0:400:4000);
+            vars.hprot = [];
+            t = 1.3;
+            alpha = 5;
+            mach = 0.4;
+            beta = 2;
+            alt = 1145;
+            c = 2;
+```
+   ).
+       
diff --git a/unitTests/TestSimulator.m b/unitTests/TestSimulator.m
deleted file mode 100644
index 50985ee4..00000000
--- a/unitTests/TestSimulator.m
+++ /dev/null
@@ -1,98 +0,0 @@
-classdef TestSimulator < UnitTest
-
-    properties
-        simulatorSettings Settings    
-        refSimulator
-    end
-
-    properties (TestParameter)
-        verifiable = {'multipleAB', 'ballistic', 'engineCut', 'HRE'};
-    end
-
-
-    methods
-        function saveTest(~, testName,  mission) 
-            Time = tic;
-
-            disp('Started saving simulator tests')
-
-            currentPath = fileparts(mfilename('fullpath'));
-            addpath(genpath(currentPath));
-
-            rocket = Rocket(mission);
-            environment = Environment(mission, rocket.motor);
-            wind = WindCustom(mission);
-            mainSimPath = fullfile('..', 'simulator', 'simulatorConfig.m');
-            mainOdePath = fullfile('..', 'common', 'settings', 'odeConfig.m');
-            SimulatorSettings = Settings(mainSimPath, mainOdePath); %#ok<*PROPLC>
-            SimulatorSettings.simulator.SMonly = 0;
-            if strcmp(testName, 'ballistic')
-                SimulatorSettings.simulator.ballistic = 1;
-                SimulatorSettings.simulator.parafoil = 0;
-            end
-
-
-            % simulator
-            [ascent, descent] = mainSimulator(rocket, wind, environment, SimulatorSettings); 
-
-            stateA = ascent(end, :);
-            stateF = descent(end, :);
-            % Save final state
-            fileName = sprintf("referenceState_%s.mat", testName);
-            folderPath = fullfile('data', 'testSimulator', testName);
-            filePath = fullfile(folderPath, fileName);
-
-            if ~exist(folderPath, "dir")
-                mkdir(folderPath)
-            end
-            save(filePath,'stateA','stateF', 'SimulatorSettings',...
-             'mission', 'rocket',...
-             'environment', 'wind');
-            
-            Time = toc(Time);
-            fprintf('\t %s test created in: %2.2f seconds\n',testName, Time)
-        
-         end
-
-        function createTestSimulator(testCase, verifiable)
-            
-
-            currentPath = fileparts(mfilename('fullpath'));
-            addpath(currentPath);
-
-            fileName = sprintf("referenceState_%s.mat", verifiable);
-            filePath = fullfile('data', 'testSimulator', verifiable, fileName);
-
-            % Load the reference file
-            testCase.rocket = load(filePath, 'rocket').rocket;
-            testCase.environment = load(filePath, 'environment').environment;
-            testCase.wind = load(filePath, 'wind').wind;
-
-            % fieldName = ['referenceState_' verifiable];
-            testCase.refSimulator = load(filePath, 'stateA', 'stateF');
-            testCase.simulatorSettings = load(filePath, 'SimulatorSettings').SimulatorSettings;
-                        
-            % Construct the file path dynamically based on the test parameter
-            
-        end
-
-    end
-
-    methods (Test)
-        function mainSimulatorTest(testCase, 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.stateA(end, :);
-            postp.stateF = postp.stateF(end, :);
-
-            % Verify results
-            testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, 'RelTol', testCase.relToll);
-        end
-    end
-end
diff --git a/unitTests/configUnitTest.m b/unitTests/configUnitTest.m
index 5851157d..ac3f075c 100644
--- a/unitTests/configUnitTest.m
+++ b/unitTests/configUnitTest.m
@@ -1,15 +1,15 @@
 % config unit-test
 
 % choose the mission
-mission = Mission("2025_Orion_Portugal_October");
+mission = Mission("2024_Lyra_Portugal_October");
 
 %% UNIT TESTS TO RUN
 % choose which folders to test
 opt.testSimulator = true;
-opt.testCommonFunction = false;
-opt.testApogeeAnalysis = false;
+opt.testCommonFunction = true;
+opt.testApogeeAnalysis = true;
 opt.testOptimization = false;
-opt.testSensitivity = false;
+opt.testSensitivity = true;
 
 
 %% UNIT TEST TO CREATE
diff --git a/unitTests/data/testApogeeAnalysis/engineCutApogee/refEngineCut.mat b/unitTests/data/testApogeeAnalysis/engineCutApogee/refEngineCut.mat
index 1bb29b4a..359f3a9b 100644
--- a/unitTests/data/testApogeeAnalysis/engineCutApogee/refEngineCut.mat
+++ b/unitTests/data/testApogeeAnalysis/engineCutApogee/refEngineCut.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:41d3a3832118fca2c05ace1d5dd5fa0ec4c9a7ef3576fc03f95b57ae851e2b70
-size 50239924
+oid sha256:6ab00feb5e7b93b46fe3e77d62d0b67f98a1debc72aa7b1ba86d66e77df1f4a5
+size 50240006
diff --git a/unitTests/data/testApogeeAnalysis/standardApogee/refStandard.mat b/unitTests/data/testApogeeAnalysis/standardApogee/refStandard.mat
index 46298514..5ac641ca 100644
--- a/unitTests/data/testApogeeAnalysis/standardApogee/refStandard.mat
+++ b/unitTests/data/testApogeeAnalysis/standardApogee/refStandard.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:db8c120bd70067997757b646cea03fbc7ddc66dab1b1683b7a63c97a6bcc0dee
-size 50241818
+oid sha256:0d7d2f10d7520076f4dbea7d1c5d982120219defed409c15ff17ce30570cad7b
+size 50241899
diff --git a/unitTests/data/testCommonFunctions/createDissileInput/refInput.mat b/unitTests/data/testCommonFunctions/createDissileInput/refInput.mat
new file mode 100644
index 00000000..025d6d8c
--- /dev/null
+++ b/unitTests/data/testCommonFunctions/createDissileInput/refInput.mat
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:063d9c363447bb8aee2ba2de7dfe45cdba346bd2679e720d0671f7e0afbbfe11
+size 50211135
diff --git a/unitTests/data/testCommonFunctions/interpCoeffs/refInterpCoeffs.mat b/unitTests/data/testCommonFunctions/interpCoeffs/refInterpCoeffs.mat
new file mode 100644
index 00000000..2467498b
--- /dev/null
+++ b/unitTests/data/testCommonFunctions/interpCoeffs/refInterpCoeffs.mat
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:14885146f15842dc50fece6c81fe325003df755e4d9c3abcc0b5b2fd1408b2ca
+size 50202726
diff --git a/unitTests/data/testCommonFunctions/refInterpCoeffs.mat b/unitTests/data/testCommonFunctions/refInterpCoeffs.mat
new file mode 100644
index 00000000..e4f6f0ac
--- /dev/null
+++ b/unitTests/data/testCommonFunctions/refInterpCoeffs.mat
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac059678dbc394536a279f7a26dd5be98899d06e3971aadeb5862c17c5223be4
+size 50202726
diff --git a/unitTests/data/testSensitivityAnalysis/refSensitivity.mat b/unitTests/data/testSensitivityAnalysis/refSensitivity.mat
index dc89c438..d4064297 100644
--- a/unitTests/data/testSensitivityAnalysis/refSensitivity.mat
+++ b/unitTests/data/testSensitivityAnalysis/refSensitivity.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:bec9a396baa955f6fd2d21639fdac82e82d4cdf5b7b3ddf21fef1cf37110c4d8
-size 51425920
+oid sha256:7793f5a29a782994ca02833fc7dc1d47625708225c1fe6916bc777b829f69319
+size 50500418
diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat
index 8cfc399f..12b1c78d 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:6b06e877dfda0149f4c9d53923e00b26c8564dcb427fe7f4978cd46ec8b68d12
-size 51436842
+oid sha256:64b1a57785c5010effbcd86848c436686ec4f46217dedb8bef14263a28ae9600
+size 51412338
diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat
index 9543c585..61423945 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:946f4c8524c558b73f4d6a53fb920977215b32c220f543137d7a2d4e64c26a14
-size 50932249
+oid sha256:b28f0806bf11633877df4b9972d74f80e1414847d7ad8a72ab340e38e4c2dbe3
+size 50580427
diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
index b2085380..ccc82ffa 100644
--- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
+++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:bdac77ac3b3731765a85ba913bc46a1300de5e737d10b1d47dbf6fe51678a626
-size 51365870
+oid sha256:a9bf532733ce28926f48eb93aa3f108c35f8672745586cd3004d62b96c4ecc2d
+size 51346297
diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
index e609d3ee..edcd85c4 100644
--- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
+++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:2d0f9d4689fa88721f6eacf21795d02bd133e117ca1ce9b3df6d46960293a7e8
-size 51421916
+oid sha256:353e173b54c360b7ae40384cb84823dde1fa20be6f6ab9c4bcb49e24ae553798
+size 51414505
diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat
new file mode 100644
index 00000000..6046d942
--- /dev/null
+++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f1906cbbc15dd617cacf494f64fa1fb9e2f19ed3de51efc8777b495d9c8b0918
+size 51461263
diff --git a/unitTests/mainUnitTest.m b/unitTests/mainUnitTest.m
index 9a310473..27290090 100644
--- a/unitTests/mainUnitTest.m
+++ b/unitTests/mainUnitTest.m
@@ -1,7 +1,7 @@
 % main unit-test
 
 currentPath = fileparts(mfilename('fullpath'));
-addpath(genpath(currentPath));
+addpath(genpath(fullfile(currentPath, '..')));
 
 configUnitTest;
 
diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m
index f0be2f42..01747012 100644
--- a/unitTests/saveTests.m
+++ b/unitTests/saveTests.m
@@ -15,7 +15,18 @@ end
 
 %% TEST COMMONFUNCTIONS
 if opt.createTestCommonFunction
-    TestCommonFunctions.saveTest(mission);
+    vars.mach = 0.05:0.05:1;
+    vars.alpha = [-10 -7.5 -5 -2.5 -1 -0.5 -0.1 0 0.1 0.5 1 2.5 5 7.5 10];
+    vars.beta = [-2.5 -0.1 0 0.1 2.5];
+    vars.alt = (0:400:4000);
+    vars.hprot = [];
+    t = 1.3;
+    alpha = 5;
+    mach = 0.4;
+    beta = 2;
+    alt = 1145;
+    c = 2;
+    TestCommonFunctions.saveTest(mission, vars, t, alpha, mach, beta, alt, c);
 end
 
 %% TEST APOGEE ANALYSIS
diff --git a/unitTests/TestApogeeAnalysis.m b/unitTests/tests/TestApogeeAnalysis.m
similarity index 56%
rename from unitTests/TestApogeeAnalysis.m
rename to unitTests/tests/TestApogeeAnalysis.m
index 5f77e953..4c1ee6f1 100644
--- a/unitTests/TestApogeeAnalysis.m
+++ b/unitTests/tests/TestApogeeAnalysis.m
@@ -11,11 +11,11 @@ classdef TestApogeeAnalysis < UnitTest
             currentPath = fileparts(mfilename("fullpath"));
             addpath(genpath(currentPath));
 
-            testCase.refStandardResults = load(fullfile(currentPath, "data", "testApogeeAnalysis", "standardApogee", "refStandard.mat")).refStandard;
-            testCase.refEngineCutResults = load(fullfile(currentPath, "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).refEngineCut;
-            testCase.apogeeAnalysisSettings = load(fullfile(currentPath, "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).apogeeAnalysisSettings;
+            testCase.refStandardResults     = load(fullfile(currentPath,'..', "data", "testApogeeAnalysis", "standardApogee", "refStandard.mat")).refStandard;
+            testCase.refEngineCutResults    = load(fullfile(currentPath,'..', "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).refEngineCut;
+            testCase.apogeeAnalysisSettings = load(fullfile(currentPath,'..', "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).apogeeAnalysisSettings;
 
-            testCase.rocket = load(fullfile(currentPath, "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).rocket;
+            testCase.rocket = load(fullfile(currentPath, '..', "data", "testApogeeAnalysis", "engineCutApogee", "refEngineCut.mat")).rocket;
         end
     end
 
@@ -23,19 +23,21 @@ classdef TestApogeeAnalysis < UnitTest
         function saveTest(mission)
             totTime = tic;
             currentPath = fileparts(mfilename('fullpath'));
-            configPath = fullfile(currentPath, "data", "testApogeeAnalysis");
+            testPath = fullfile(currentPath, '..', "data", "testApogeeAnalysis");
             addpath(genpath(currentPath));
 
             disp('Started saving apogee analysis tests')
 
             rocket = Rocket(mission);
 
-            [refStandard, refEngineCut, apogeeAnalysisSettings] = mainApogeeAnalysis(rocket);
+            mainApoPath = fullfile('..', '..', 'apogeeAnalysis', 'apogeeAnalysisConfig.m');
+            mainOdePath = fullfile('..', '..', 'common', 'settings', 'odeConfig.m');
+            apogeeAnalysisSettings = Settings(mainApoPath, mainOdePath);
 
-            %apogeeAnalysisSettings = Settings("apogeeAnalysis");
+            [refStandard, refEngineCut] = mainApogeeAnalysis(rocket, apogeeAnalysisSettings);
             
-            save(fullfile(configPath, "standardApogee", "refStandard.mat") , "refStandard", "apogeeAnalysisSettings", "rocket");
-            save(fullfile(configPath, "engineCutApogee", "refEngineCut.mat"), "refEngineCut", "apogeeAnalysisSettings", "rocket");
+            save(fullfile(testPath, "standardApogee", "refStandard.mat") , "refStandard", "apogeeAnalysisSettings", "rocket");
+            save(fullfile(testPath, "engineCutApogee", "refEngineCut.mat"), "refEngineCut", "apogeeAnalysisSettings", "rocket");
 
             clearvars -except totTime paths totTime opt
             close all;
diff --git a/unitTests/TestCommonFunctions.m b/unitTests/tests/TestCommonFunctions.m
similarity index 56%
rename from unitTests/TestCommonFunctions.m
rename to unitTests/tests/TestCommonFunctions.m
index 2e565cc1..2936d1da 100644
--- a/unitTests/TestCommonFunctions.m
+++ b/unitTests/tests/TestCommonFunctions.m
@@ -25,21 +25,21 @@ classdef TestCommonFunctions < UnitTest
             currentPath = fileparts(mfilename('fullpath'));
             addpath(genpath(currentPath));
             
-            testCase.refCoeffsValue = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).refCoeffsValue;
-            testCase.refAngles = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).refAngles;
-            testCase.refInputValue = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'createDissileInput', 'refInput.mat')).refInput;
+            testCase.refCoeffsValue = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).refCoeffsValue;
+            testCase.refAngles      = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).refAngles;
+            testCase.refInputValue  = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'createDissileInput', 'refInput.mat')).refInput;
             
-            testCase.rocket = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).rocket;
-            testCase.vars = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'createDissileInput', 'refInput.mat')).vars;
-            testCase.t = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).t;
-            testCase.alpha = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).alpha;
-            testCase.mach = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).mach;
-            testCase.beta = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).beta;
-            testCase.alt = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).alt;
-            testCase.c = load(fullfile(currentPath, 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).c;
-
-            testCase.vars.xcg = testCase.rocket.xCg;
-            testCase.cutoffTime = testCase.rocket.motor.cutoffTime;
+            testCase.rocket = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).rocket;
+            testCase.vars   = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'createDissileInput', 'refInput.mat')).vars;
+            testCase.t      = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).t;
+            testCase.alpha  = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).alpha;
+            testCase.mach   = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).mach;
+            testCase.beta   = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).beta;
+            testCase.alt    = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).alt;
+            testCase.c      = load(fullfile(currentPath,'..', 'data', 'testCommonFunctions', 'interpCoeffs', 'refInterpCoeffs.mat')).c;
+
+            testCase.vars.xcg     = testCase.rocket.xCg;
+            testCase.cutoffTime   = testCase.rocket.motor.cutoffTime;
             testCase.coefficients = testCase.rocket.coefficients;
 
          end
@@ -47,10 +47,22 @@ classdef TestCommonFunctions < UnitTest
 
     methods (Static)
 
+        % vars.mach = 0.05:0.05:1;
+        % vars.alpha = [-10 -7.5 -5 -2.5 -1 -0.5 -0.1 0 0.1 0.5 1 2.5 5 7.5 10];
+        % vars.beta = [-2.5 -0.1 0 0.1 2.5];
+        % vars.alt = (0:400:4000);
+        % vars.hprot = [];
+        % t = 1.3;
+        % alpha = 5;
+        % mach = 0.4;
+        % beta = 2;
+        % alt = 1145;
+        % c = 2;
+
         function saveTest(mission, vars, t, alpha, mach, beta, alt, c)
             currentPath = fileparts(mfilename('fullpath'));
             addpath(genpath(currentPath));
-            cmnfnctnPath = fullfile(currentPath, 'data', 'testCommonFunctions');
+            testPath = fullfile(currentPath,'..', 'data', 'testCommonFunctions');
 
             totTime = tic;
             disp('Started saving common functions tests');
@@ -66,7 +78,7 @@ classdef TestCommonFunctions < UnitTest
             [refCoeffsValue, refAngles] = interpCoeffs(coefficients, ...
                 t, cutoffTime, alpha, mach, beta, alt, c);
 
-            save(fullfile(cmnfnctnPath, 'interpCoeffs', 'refInterpCoeffs'), 'refCoeffsValue', 'refAngles', ...
+            save(fullfile(testPath, 'interpCoeffs', 'refInterpCoeffs'), 'refCoeffsValue', 'refAngles', ...
                 'mission', 'rocket', 't', 'alpha', 'mach', 'beta', 'alt', 'c');
 
             interpCoeffsTime = toc(interpCoeffsTime);
@@ -77,7 +89,7 @@ classdef TestCommonFunctions < UnitTest
 
             [refInput] = createDissileInput(rocket, vars);
 
-            save(fullfile(cmnfnctnPath, 'createDissileInput', 'refInput'), 'refInput', 'mission', 'rocket', 'vars');
+            save(fullfile(testPath, 'createDissileInput', 'refInput'), 'refInput', 'mission', 'rocket', 'vars');
             
             createDissileInputTime = toc(createDissileInputTime);
             fprintf('\createDissileInput test created in: %2.2f seconds\n', createDissileInputTime);
@@ -91,7 +103,7 @@ classdef TestCommonFunctions < UnitTest
     end
 
     methods (Test)
-        function interpCoeffs(testCase)
+        function interpCoeffsTest(testCase)
             % interpCoeffs
             cmnfnctnPath = fullfile('..', 'common', 'functions');
             addpath(genpath(cmnfnctnPath));
@@ -105,7 +117,7 @@ classdef TestCommonFunctions < UnitTest
             testCase.verifyEqual(angles, testCase.refAngles);
         end
 
-        function createDissileInput(testCase)
+        function createDissileInputTest(testCase)
             % createDissileInput
             cmnfnctnPath = fullfile('..', 'common', 'functions');
             addpath(genpath(cmnfnctnPath));
diff --git a/unitTests/TestSensitivity.m b/unitTests/tests/TestSensitivity.m
similarity index 74%
rename from unitTests/TestSensitivity.m
rename to unitTests/tests/TestSensitivity.m
index e3a1f694..ee464ef4 100644
--- a/unitTests/TestSensitivity.m
+++ b/unitTests/tests/TestSensitivity.m
@@ -11,7 +11,7 @@ classdef TestSensitivity < UnitTest
         function createTest(testCase)
             currentPath = fileparts(mfilename('fullpath'));
             addpath(genpath(currentPath));
-            filePath = fullfile('data', 'testSensitivityAnalysis', 'refSensitivity');
+            filePath = fullfile(currentPath, '..', 'data', 'testSensitivityAnalysis', 'refSensitivity');
 
             testCase.refSensitivity = load(filePath).refSensitivity;
             testCase.sensitivitySettings = load(filePath).sensitivitySettings;
@@ -28,18 +28,20 @@ classdef TestSensitivity < UnitTest
 
             currentPath = fileparts(mfilename('fullpath'));
             addpath(genpath(currentPath));  
-            folderPath = fullfile(currentPath, 'data', 'testSensitivityAnalysis');
-            configPath = fullfile(folderPath, 'refSensitivity,m');
+            folderPath = fullfile(currentPath,'..', 'data', 'testSensitivityAnalysis');
+            configPath = fullfile(folderPath, 'refSensitivity');
     
             disp('Started saving sensitivity analysis tests')
 
             rocket = Rocket(mission);
             environment = Environment(mission, rocket.motor);
             wind = WindCustom(mission);
+            mainSensPath = fullfile('..', '..', 'sensitivityAnalysis', 'sensitivityConfig.m');
+            mainOdePath = fullfile('..', '..', 'common', 'settings', 'odeConfig.m');
+            sensitivitySettings = Settings(mainSensPath, mainOdePath);
+            sensitivitySettings.sensitivity.plots.enabled = false;
           
-            [refSensitivity] = mainSensitivity(rocket, wind, environment);
-
-            sensitivitySettings = Settings('sensitivity');
+            [refSensitivity] = mainSensitivity(rocket, wind, environment, sensitivitySettings);
 
             if ~exist(folderPath, "dir")
                 mkdir(folderPath)
@@ -48,7 +50,6 @@ classdef TestSensitivity < UnitTest
             save(configPath, "refSensitivity", 'sensitivitySettings', 'rocket', 'environment', 'wind');
 
             time = toc(totTime);
-            close all
             clearvars -except opt paths time
             fprintf('Sensitivity analysis tests created in: %2.2f seconds\n\n', time)
         end
@@ -58,14 +59,12 @@ classdef TestSensitivity < UnitTest
         function sensitivityAnalysis(testCase)
             testCase.createTest();
 
-            mainSensPath = fullfile('..', 'sensitivityAnalysis');
-            addpath(mainSensPath);
+            mainSensPath = fullfile('..', '..', 'sensitivityAnalysis');
+            addpath(genpath(mainSensPath));
 
             % check analysis
             [postp] = mainSensitivity(testCase.rocket, testCase.wind, testCase.environment, testCase.sensitivitySettings);
 
-            close all;
-
             testCase.verifyEqual(postp, testCase.refSensitivity, 'AbsTol', testCase.absToll, ...
                 'RelTol', testCase.relToll);
 
diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m
new file mode 100644
index 00000000..4f4b8625
--- /dev/null
+++ b/unitTests/tests/TestSimulator.m
@@ -0,0 +1,111 @@
+classdef TestSimulator < UnitTest
+
+    % TEST FUNZIONANTE, DA RISOLVERE PATH PER simulatorConfig.m in saveTest
+    % MANCA refSolid
+
+    properties
+        simulatorSettings
+        refSimulator
+    end
+
+    properties (TestParameter)
+        verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};
+    end
+
+    methods
+        function createTest(testCase, verifiable)
+            currentPath = fileparts(mfilename('fullpath'));
+            addpath(genpath(currentPath));
+
+            fileName = sprintf("referenceState_%s.mat", verifiable);
+            filePath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable, fileName);
+
+            % Load the reference file
+            testCase.rocket = load(filePath, 'rocket').rocket;
+            testCase.environment = load(filePath, 'environment').environment;
+            testCase.wind = load(filePath, 'wind').wind;
+
+            % fieldName = ['referenceState_' verifiable];
+            testCase.refSimulator.stateA = load(filePath).stateA;
+            testCase.refSimulator.stateF = load(filePath).stateF;
+
+            testCase.simulatorSettings = load(filePath).simulatorSettings;
+                        
+            % Construct the file path dynamically based on the test parameter
+        end
+    end
+
+
+
+    methods (Static)
+        function saveTest(verifiable,  mission)
+            Time = tic;
+
+            disp('Started saving simulator tests')
+
+            mainSimPath = fullfile('..', '..', 'simulator');
+            addpath(genpath(mainSimPath));
+            currentPath = fileparts(mfilename('fullpath'));
+            addpath(genpath(currentPath));
+
+            rocket = Rocket(mission);
+            environment = Environment(mission, rocket.motor);
+            wind = WindCustom(mission);
+
+            mainSimPath = fullfile('..', '..', 'simulator', 'simulatorConfig.m');
+            mainOdePath = fullfile('..', '..', 'common', 'settings', 'odeConfig.m');
+            simulatorSettings = Settings(mainSimPath, mainOdePath);
+            simulatorSettings.simulator.SMonly = 0;
+            if strcmp(verifiable, 'ballistic')
+                simulatorSettings.simulator.ballistic = 1;
+                simulatorSettings.simulator.parafoil = 0;
+            end
+           
+            % simulator
+            [stateA, stateF] = mainSimulator(rocket, wind, environment, simulatorSettings);
+
+            mainSimPath = fullfile('..', '..', 'simulator', 'simulatorConfig.m');
+            mainOdePath = fullfile('..', '..', 'common', 'settings', 'odeConfig.m');
+            simulatorSettings = Settings(mainSimPath, mainOdePath);
+            simulatorSettings.simulator.SMonly = 0;
+            if strcmp(verifiable, 'ballistic')
+                simulatorSettings.simulator.ballistic = 1;
+                simulatorSettings.simulator.parafoil = 0;
+            end
+
+            % Save final state
+            fileName = sprintf("referenceState_%s.mat", verifiable);
+            folderPath = fullfile(currentPath,'..',  'data', 'testSimulator', verifiable);
+            filePath = fullfile(folderPath, fileName);
+
+            if ~exist(folderPath, "dir")
+                mkdir(folderPath)
+            end
+            save(filePath,'stateA','stateF', 'simulatorSettings',...
+             'mission', 'rocket', 'environment', 'wind');
+
+            close all; 
+            
+            Time = toc(Time);
+            fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time)
+         end
+    end
+
+    methods (Test)
+        function mainSimulatorTest(testCase, verifiable)
+            
+            testCase.createTest(verifiable);
+
+            mainSimPath = fullfile('..', '..', 'simulator');
+            addpath(genpath(mainSimPath));
+
+            % Run main simulator
+            [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.simulatorSettings);
+            
+            close all;
+
+            % Verify results
+            testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, 'RelTol', testCase.relToll);
+        end
+    end
+end
diff --git a/unitTests/UnitTest.m b/unitTests/tests/UnitTest.m
similarity index 100%
rename from unitTests/UnitTest.m
rename to unitTests/tests/UnitTest.m
diff --git a/unitTests/unitTestsOld/README.md b/unitTests/unitTestsOld/README.md
new file mode 100644
index 00000000..3593b687
--- /dev/null
+++ b/unitTests/unitTestsOld/README.md
@@ -0,0 +1,12 @@
+# unitTests
+This folder contains all the scripts to create and perform unit tests on the toolkit, using data that is known to be correct.
+
+## Usage
+You can use <code>createTests.m</code> to create new reference data for the tests if you are sure that the toolkit works properly.
+
+To run the tests you have to set the config in <code>configUnitTests.m</code> and then run <code>mainUnitTests.m</code>.
+
+However, you have to set the absolute and relative tolerance for each test in each script (e.g. <code>src/simulatorUnitTests.m</code>).
+
+## Output
+The program displays in the command window wheter the toolkit has passed each particular test or not.
\ No newline at end of file
diff --git a/unitTests/unitTestOld/artifacts/results.xml b/unitTests/unitTestsOld/artifacts/results.xml
similarity index 100%
rename from unitTests/unitTestOld/artifacts/results.xml
rename to unitTests/unitTestsOld/artifacts/results.xml
diff --git a/unitTests/unitTestOld/configUnitTests.m b/unitTests/unitTestsOld/configUnitTestsOld.m
similarity index 100%
rename from unitTests/unitTestOld/configUnitTests.m
rename to unitTests/unitTestsOld/configUnitTestsOld.m
diff --git a/unitTests/unitTestOld/createTests.m b/unitTests/unitTestsOld/createTestsOld.m
similarity index 100%
rename from unitTests/unitTestOld/createTests.m
rename to unitTests/unitTestsOld/createTestsOld.m
diff --git a/unitTests/unitTestOld/dataOld/HRE_FURIA-EUROC-T04T03.mat b/unitTests/unitTestsOld/dataOld/HRE_FURIA-EUROC-T04T03.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/HRE_FURIA-EUROC-T04T03.mat
rename to unitTests/unitTestsOld/dataOld/HRE_FURIA-EUROC-T04T03.mat
diff --git a/unitTests/unitTestOld/dataOld/SRM_M1520-BS.mat b/unitTests/unitTestsOld/dataOld/SRM_M1520-BS.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/SRM_M1520-BS.mat
rename to unitTests/unitTestsOld/dataOld/SRM_M1520-BS.mat
diff --git a/unitTests/unitTestOld/dataOld/geminiData.m b/unitTests/unitTestsOld/dataOld/geminiData.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/geminiData.m
rename to unitTests/unitTestsOld/dataOld/geminiData.m
diff --git a/unitTests/unitTestOld/dataOld/pyxisData.m b/unitTests/unitTestsOld/dataOld/pyxisData.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/pyxisData.m
rename to unitTests/unitTestsOld/dataOld/pyxisData.m
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/config.m b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/config.m
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/config.m
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/dataEC.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/dataEC.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/dataEC.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/dataEC.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEC.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEC.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEC.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEC.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEngineCut.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEngineCut.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEngineCut.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/engineCutApogee/referenceEngineCut.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/configHYB.m b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/configHYB.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/configHYB.m
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/configHYB.m
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/configSLD.m b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/configSLD.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/configSLD.m
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/configSLD.m
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/dataHYB.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/dataHYB.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/dataHYB.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/dataHYB.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/dataSOLID.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/dataSOLID.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/dataSOLID.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/dataSOLID.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceHYB.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceHYB.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceHYB.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceHYB.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceSOLID.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceSOLID.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceSOLID.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceSOLID.mat
diff --git a/unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceStandard.mat b/unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceStandard.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testApogeeAnalysis/standardApogee/referenceStandard.mat
rename to unitTests/unitTestsOld/dataOld/testApogeeAnalysis/standardApogee/referenceStandard.mat
diff --git a/unitTests/unitTestOld/dataOld/testCommonFunctions/createDissileInput/config.m b/unitTests/unitTestsOld/dataOld/testCommonFunctions/createDissileInput/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testCommonFunctions/createDissileInput/config.m
rename to unitTests/unitTestsOld/dataOld/testCommonFunctions/createDissileInput/config.m
diff --git a/unitTests/unitTestOld/dataOld/testCommonFunctions/createDissileInput/referenceInputValue.mat b/unitTests/unitTestsOld/dataOld/testCommonFunctions/createDissileInput/referenceInputValue.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testCommonFunctions/createDissileInput/referenceInputValue.mat
rename to unitTests/unitTestsOld/dataOld/testCommonFunctions/createDissileInput/referenceInputValue.mat
diff --git a/unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/angles.mat b/unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/angles.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/angles.mat
rename to unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/angles.mat
diff --git a/unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/coeffsValue.mat b/unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/coeffsValue.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/coeffsValue.mat
rename to unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/coeffsValue.mat
diff --git a/unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/config.m b/unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testCommonFunctions/interpCoeffs/config.m
rename to unitTests/unitTestsOld/dataOld/testCommonFunctions/interpCoeffs/config.m
diff --git a/unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config1.m b/unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config1.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config1.m
rename to unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config1.m
diff --git a/unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config2.m b/unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config2.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config2.m
rename to unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config2.m
diff --git a/unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config3.m b/unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config3.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config3.m
rename to unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config3.m
diff --git a/unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config4.m b/unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config4.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testOptimization/singleGARun/config4.m
rename to unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/config4.m
diff --git a/unitTests/unitTestOld/dataOld/testOptimization/singleGARun/refOptGA.mat b/unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/refOptGA.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testOptimization/singleGARun/refOptGA.mat
rename to unitTests/unitTestsOld/dataOld/testOptimization/singleGARun/refOptGA.mat
diff --git a/unitTests/unitTestOld/dataOld/testSensitivityAnalysis/config.m b/unitTests/unitTestsOld/dataOld/testSensitivityAnalysis/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSensitivityAnalysis/config.m
rename to unitTests/unitTestsOld/dataOld/testSensitivityAnalysis/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSensitivityAnalysis/referenceSensitivity.mat b/unitTests/unitTestsOld/dataOld/testSensitivityAnalysis/referenceSensitivity.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSensitivityAnalysis/referenceSensitivity.mat
rename to unitTests/unitTestsOld/dataOld/testSensitivityAnalysis/referenceSensitivity.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/6DOF/config.m b/unitTests/unitTestsOld/dataOld/testSimulator/6DOF/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/6DOF/config.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/6DOF/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/6DOF/referenceState6DOF.mat b/unitTests/unitTestsOld/dataOld/testSimulator/6DOF/referenceState6DOF.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/6DOF/referenceState6DOF.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/6DOF/referenceState6DOF.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/ballistic/config.m b/unitTests/unitTestsOld/dataOld/testSimulator/ballistic/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/ballistic/config.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/ballistic/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/ballistic/referenceStateBallistic.mat b/unitTests/unitTestsOld/dataOld/testSimulator/ballistic/referenceStateBallistic.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/ballistic/referenceStateBallistic.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/ballistic/referenceStateBallistic.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/engineCut/config.m b/unitTests/unitTestsOld/dataOld/testSimulator/engineCut/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/engineCut/config.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/engineCut/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/multiple_AB/config.m b/unitTests/unitTestsOld/dataOld/testSimulator/multiple_AB/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/multiple_AB/config.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/multiple_AB/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/multiple_AB/referenceState_multipleAB.mat b/unitTests/unitTestsOld/dataOld/testSimulator/multiple_AB/referenceState_multipleAB.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/multiple_AB/referenceState_multipleAB.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/multiple_AB/referenceState_multipleAB.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config1.m b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config1.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config1.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config1.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config2.m b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config2.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config2.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config2.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config3.m b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config3.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/config3.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/config3.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB1.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB2.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat b/unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_HRE/referenceState_std_HRE_ARB3.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_solid/config.m b/unitTests/unitTestsOld/dataOld/testSimulator/standard_solid/config.m
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_solid/config.m
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_solid/config.m
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/standard_solid/referenceState_std_solid.mat b/unitTests/unitTestsOld/dataOld/testSimulator/standard_solid/referenceState_std_solid.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/standard_solid/referenceState_std_solid.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/standard_solid/referenceState_std_solid.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/windModels/referenceWindInputComponents.mat b/unitTests/unitTestsOld/dataOld/testSimulator/windModels/referenceWindInputComponents.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/windModels/referenceWindInputComponents.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/windModels/referenceWindInputComponents.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/windModels/referenceWindVariableComponents.mat b/unitTests/unitTestsOld/dataOld/testSimulator/windModels/referenceWindVariableComponents.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/windModels/referenceWindVariableComponents.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/windModels/referenceWindVariableComponents.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/windModels/windInputComponents.mat b/unitTests/unitTestsOld/dataOld/testSimulator/windModels/windInputComponents.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/windModels/windInputComponents.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/windModels/windInputComponents.mat
diff --git a/unitTests/unitTestOld/dataOld/testSimulator/windModels/windVariableComponents.mat b/unitTests/unitTestsOld/dataOld/testSimulator/windModels/windVariableComponents.mat
similarity index 100%
rename from unitTests/unitTestOld/dataOld/testSimulator/windModels/windVariableComponents.mat
rename to unitTests/unitTestsOld/dataOld/testSimulator/windModels/windVariableComponents.mat
diff --git a/unitTests/unitTestOld/mainUnitTests.m b/unitTests/unitTestsOld/mainUnitTestsOld.m
similarity index 100%
rename from unitTests/unitTestOld/mainUnitTests.m
rename to unitTests/unitTestsOld/mainUnitTestsOld.m
diff --git a/unitTests/unitTestOld/src/apogeeCreateTests.m b/unitTests/unitTestsOld/src/apogeeCreateTests.m
similarity index 100%
rename from unitTests/unitTestOld/src/apogeeCreateTests.m
rename to unitTests/unitTestsOld/src/apogeeCreateTests.m
diff --git a/unitTests/unitTestOld/src/cmnFnctnCreateTests.m b/unitTests/unitTestsOld/src/cmnFnctnCreateTests.m
similarity index 100%
rename from unitTests/unitTestOld/src/cmnFnctnCreateTests.m
rename to unitTests/unitTestsOld/src/cmnFnctnCreateTests.m
diff --git a/unitTests/unitTestOld/src/optCreateTests.m b/unitTests/unitTestsOld/src/optCreateTests.m
similarity index 100%
rename from unitTests/unitTestOld/src/optCreateTests.m
rename to unitTests/unitTestsOld/src/optCreateTests.m
diff --git a/unitTests/unitTestOld/src/sensitivityCreateTests.m b/unitTests/unitTestsOld/src/sensitivityCreateTests.m
similarity index 100%
rename from unitTests/unitTestOld/src/sensitivityCreateTests.m
rename to unitTests/unitTestsOld/src/sensitivityCreateTests.m
diff --git a/unitTests/unitTestOld/src/simulatorCreateTests.m b/unitTests/unitTestsOld/src/simulatorCreateTests.m
similarity index 100%
rename from unitTests/unitTestOld/src/simulatorCreateTests.m
rename to unitTests/unitTestsOld/src/simulatorCreateTests.m
diff --git a/unitTests/unitTestsOld/testsOld/apogeeUnitTests.m b/unitTests/unitTestsOld/testsOld/apogeeUnitTests.m
new file mode 100644
index 00000000..678ed544
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/apogeeUnitTests.m
@@ -0,0 +1,114 @@
+%{
+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/unitTestsOld/testsOld/artifacts/results.xml b/unitTests/unitTestsOld/testsOld/artifacts/results.xml
new file mode 100644
index 00000000..331354a0
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/artifacts/results.xml
@@ -0,0 +1,181 @@
+<?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/unitTestsOld/testsOld/checkErrorMSA.m b/unitTests/unitTestsOld/testsOld/checkErrorMSA.m
new file mode 100644
index 00000000..ef55400d
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/checkErrorMSA.m
@@ -0,0 +1,46 @@
+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/unitTestsOld/testsOld/cmnFnctnUnitTests.m b/unitTests/unitTestsOld/testsOld/cmnFnctnUnitTests.m
new file mode 100644
index 00000000..494e6a1b
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/cmnFnctnUnitTests.m
@@ -0,0 +1,51 @@
+%{
+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/unitTestsOld/testsOld/optUnitTests.m b/unitTests/unitTestsOld/testsOld/optUnitTests.m
new file mode 100644
index 00000000..e966ad35
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/optUnitTests.m
@@ -0,0 +1,93 @@
+%{
+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/unitTestsOld/testsOld/runTest.m b/unitTests/unitTestsOld/testsOld/runTest.m
new file mode 100644
index 00000000..f241a451
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/runTest.m
@@ -0,0 +1,18 @@
+% 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/unitTestsOld/testsOld/sensitivityUnitTests.m b/unitTests/unitTestsOld/testsOld/sensitivityUnitTests.m
new file mode 100644
index 00000000..a53b83fe
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/sensitivityUnitTests.m
@@ -0,0 +1,55 @@
+%{
+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/unitTestsOld/testsOld/simulatorUnitTests.m b/unitTests/unitTestsOld/testsOld/simulatorUnitTests.m
new file mode 100644
index 00000000..820156d8
--- /dev/null
+++ b/unitTests/unitTestsOld/testsOld/simulatorUnitTests.m
@@ -0,0 +1,210 @@
+%{
+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)
-- 
GitLab