merge
This commit is contained in:
commit
d8e0341742
@ -7,6 +7,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Google Test framework
|
||||
FetchContent_Declare(googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest
|
||||
GIT_TAG v1.13.0)
|
||||
if(WIN32)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
# fmtlib dependency
|
||||
FetchContent_Declare(fmt
|
||||
GIT_REPOSITORY https://github.com/fmtlib/fmt
|
||||
@ -91,52 +100,6 @@ set(PROJECT_SOURCES
|
||||
gui/ThrustCurveMotorSelector.ui
|
||||
gui/qcustomplot.cpp
|
||||
gui/qcustomplot.h
|
||||
model/MotorModel.cpp
|
||||
model/MotorModel.h
|
||||
model/MotorModelDatabase.cpp
|
||||
model/MotorModelDatabase.h
|
||||
model/Rocket.cpp
|
||||
model/Rocket.h
|
||||
model/ThrustCurve.cpp
|
||||
model/ThrustCurve.h
|
||||
sim/AtmosphericModel.h
|
||||
sim/ConstantAtmosphere.h
|
||||
sim/ConstantGravityModel.h
|
||||
sim/DESolver.h
|
||||
sim/Environment.h
|
||||
sim/GeoidModel.h
|
||||
sim/GravityModel.h
|
||||
sim/Propagator.cpp
|
||||
sim/Propagator.h
|
||||
sim/RK4Solver.h
|
||||
sim/SphericalGeoidModel.cpp
|
||||
sim/SphericalGeoidModel.h
|
||||
sim/SphericalGravityModel.cpp
|
||||
sim/SphericalGravityModel.h
|
||||
sim/StateData.h
|
||||
sim/TestRK4Solver.h
|
||||
sim/USStandardAtmosphere.cpp
|
||||
sim/USStandardAtmosphere.h
|
||||
sim/WindModel.cpp
|
||||
sim/WindModel.h
|
||||
utils/BinMap.cpp
|
||||
utils/BinMap.h
|
||||
utils/CurlConnection.cpp
|
||||
utils/CurlConnection.h
|
||||
utils/Logger.cpp
|
||||
utils/Logger.h
|
||||
utils/MotorModelDatabase.cpp
|
||||
utils/MotorModelDatabase.h
|
||||
utils/RSEDatabaseLoader.cpp
|
||||
utils/RSEDatabaseLoader.h
|
||||
utils/ThreadPool.cpp
|
||||
utils/ThreadPool.h
|
||||
utils/ThrustCurveAPI.cpp
|
||||
utils/ThrustCurveAPI.h
|
||||
utils/TSQueue.h
|
||||
utils/math/Constants.h
|
||||
utils/math/MathTypes.h
|
||||
utils/math/UtilityMathFunctions.h
|
||||
${TS_FILES}
|
||||
)
|
||||
|
||||
@ -167,7 +130,24 @@ else()
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(qtrocket PRIVATE Qt6::Widgets Qt6::PrintSupport libcurl jsoncpp_static fmt::fmt-header-only eigen)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(sim)
|
||||
add_subdirectory(model)
|
||||
|
||||
#target_link_libraries(qtrocket PRIVATE
|
||||
# Qt6::Widgets
|
||||
# Qt6::PrintSupport
|
||||
# libcurl
|
||||
# jsoncpp_static
|
||||
# fmt::fmt-header-only
|
||||
# eigen)
|
||||
|
||||
target_link_libraries(qtrocket PRIVATE
|
||||
Qt6::Widgets
|
||||
Qt6::PrintSupport
|
||||
utils
|
||||
sim
|
||||
model)
|
||||
|
||||
set_target_properties(qtrocket PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||
|
12
model/CMakeLists.txt
Normal file
12
model/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
add_library(model
|
||||
MotorModel.cpp
|
||||
MotorModel.h
|
||||
MotorModelDatabase.cpp
|
||||
MotorModelDatabase.h
|
||||
Rocket.cpp
|
||||
Rocket.h
|
||||
ThrustCurve.cpp
|
||||
ThrustCurve.h)
|
||||
|
||||
target_link_libraries(model PRIVATE
|
||||
utils)
|
26
sim/CMakeLists.txt
Normal file
26
sim/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
add_library(sim
|
||||
AtmosphericModel.h
|
||||
ConstantAtmosphere.h
|
||||
ConstantGravityModel.h
|
||||
DESolver.h
|
||||
Environment.h
|
||||
GeoidModel.h
|
||||
GravityModel.h
|
||||
Propagator.cpp
|
||||
Propagator.h
|
||||
RK4Solver.h
|
||||
SphericalGeoidModel.cpp
|
||||
SphericalGeoidModel.h
|
||||
SphericalGravityModel.cpp
|
||||
SphericalGravityModel.h
|
||||
StateData.h
|
||||
USStandardAtmosphere.cpp
|
||||
USStandardAtmosphere.h
|
||||
WindModel.cpp
|
||||
WindModel.h)
|
||||
|
||||
target_link_libraries(sim PRIVATE
|
||||
utils)
|
||||
|
||||
# Unit tests
|
||||
add_subdirectory(tests)
|
@ -10,6 +10,7 @@
|
||||
// qtrocket headers
|
||||
#include "sim/USStandardAtmosphere.h"
|
||||
#include "utils/math/Constants.h"
|
||||
#include "utils/math/UtilityMathFunctions.h"
|
||||
|
||||
using namespace utils::math;
|
||||
|
||||
@ -35,13 +36,13 @@ utils::BinMap initTemps()
|
||||
utils::BinMap initLapseRates()
|
||||
{
|
||||
utils::BinMap map;
|
||||
map.insert(std::make_pair(0.0, 0.0065));
|
||||
map.insert(std::make_pair(0.0, -0.0065));
|
||||
map.insert(std::make_pair(11000.0, 0.0));
|
||||
map.insert(std::make_pair(20000.0, -0.001));
|
||||
map.insert(std::make_pair(32000.0, -0.0028));
|
||||
map.insert(std::make_pair(20000.0, 0.001));
|
||||
map.insert(std::make_pair(32000.0, 0.0028));
|
||||
map.insert(std::make_pair(47000.0, 0.0));
|
||||
map.insert(std::make_pair(51000.0, 0.0028));
|
||||
map.insert(std::make_pair(71000.0, 0.002));
|
||||
map.insert(std::make_pair(51000.0, -0.0028));
|
||||
map.insert(std::make_pair(71000.0, -0.002));
|
||||
|
||||
return map;
|
||||
}
|
||||
@ -78,7 +79,7 @@ USStandardAtmosphere::~USStandardAtmosphere()
|
||||
|
||||
double USStandardAtmosphere::getDensity(double altitude)
|
||||
{
|
||||
if(temperatureLapseRate[altitude] == 0.0)
|
||||
if(utils::math::floatingPointEqual(temperatureLapseRate[altitude], 0.0))
|
||||
{
|
||||
return standardDensity[altitude] * std::exp((-Constants::g0 * Constants::airMolarMass * (altitude - standardDensity.getBinBase(altitude)))
|
||||
/ (Constants::Rstar * standardTemperature[altitude]));
|
||||
@ -86,11 +87,10 @@ double USStandardAtmosphere::getDensity(double altitude)
|
||||
}
|
||||
else
|
||||
{
|
||||
double base = standardTemperature[altitude] /
|
||||
(standardTemperature[altitude] + temperatureLapseRate[altitude] * (altitude - standardDensity.getBinBase(altitude)));
|
||||
double base = (standardTemperature[altitude] - temperatureLapseRate[altitude] * (altitude - standardDensity.getBinBase(altitude))) / standardTemperature[altitude];
|
||||
|
||||
double exponent = 1 + (Constants::g0 * Constants::airMolarMass) /
|
||||
(Constants::Rstar * temperatureLapseRate[altitude]);
|
||||
double exponent = (Constants::g0 * Constants::airMolarMass) /
|
||||
(Constants::Rstar * temperatureLapseRate[altitude]) - 1.0;
|
||||
|
||||
return standardDensity[altitude] * std::pow(base, exponent);
|
||||
|
||||
|
14
sim/tests/CMakeLists.txt
Normal file
14
sim/tests/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
enable_testing()
|
||||
|
||||
add_executable(sim_tests
|
||||
USStandardAtmosphereTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(sim_tests
|
||||
sim
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(sim_tests)
|
||||
|
29
sim/tests/USStandardAtmosphereTests.cpp
Normal file
29
sim/tests/USStandardAtmosphereTests.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "sim/USStandardAtmosphere.h"
|
||||
|
||||
TEST(USStandardAtmosphereTests, DensityTests)
|
||||
{
|
||||
sim::USStandardAtmosphere atmosphere;
|
||||
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(0.0), 1.225);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(1000.0), 1.112);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(2000.0), 1.007);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(3000.0), 0.9093);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(4000.0), 0.8194);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(5000.0), 0.7364);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(6000.0), 0.6601);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(7000.0), 0.5900);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(8000.0), 0.5258);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(9000.0), 0.4647);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(10000.0), 0.4135);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(15000.0), 0.1948);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(20000.0), 0.08891);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(25000.0), 0.04008);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(30000.0), 0.01841);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(40000.0), 0.003996);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(50000.0), 0.001027);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(60000.0), 0.0003097);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(70000.0), 0.00008283);
|
||||
EXPECT_DOUBLE_EQ(atmosphere.getDensity(80000.0), 0.00001846);
|
||||
}
|
25
utils/CMakeLists.txt
Normal file
25
utils/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
add_library(utils
|
||||
BinMap.cpp
|
||||
BinMap.h
|
||||
CurlConnection.cpp
|
||||
CurlConnection.h
|
||||
Logger.cpp
|
||||
Logger.h
|
||||
MotorModelDatabase.cpp
|
||||
MotorModelDatabase.h
|
||||
RSEDatabaseLoader.cpp
|
||||
RSEDatabaseLoader.h
|
||||
ThreadPool.cpp
|
||||
ThreadPool.h
|
||||
ThrustCurveAPI.cpp
|
||||
ThrustCurveAPI.h
|
||||
TSQueue.h
|
||||
math/Constants.h
|
||||
math/MathTypes.h
|
||||
math/UtilityMathFunctions.h)
|
||||
|
||||
target_link_libraries(utils PUBLIC
|
||||
libcurl
|
||||
jsoncpp_static
|
||||
fmt::fmt-header-only
|
||||
eigen)
|
Loading…
x
Reference in New Issue
Block a user