Skip to content
Snippets Groups Projects
Select Git revision
  • d44525ab2941d96177982875578c80cb1ea9709b
  • master default protected
  • feature/diffraction-w-mat
  • feature/plane-diffraction
  • develop protected
  • feature/unit-tests
  • newPathEngineImplementation
  • ma23-mika-fiddling
  • feature/art_eigenray_search_apriori
  • ma_schnabel
  • psc
  • ray_tracing
  • ma_2018/erraji
  • ITAPropagationPathSim_v2024a
  • VA_v2023b
  • ART_v2023a
  • VA_v2023a
  • VA_v2022a
  • before_cmake_rework
  • ARTMatlab_v2021b
  • v2021.a
  • v2019.a
  • v2016.a
23 results

SimulationEngineTest.cpp

  • Philipp Schäfer's avatar
    Philipp Schäfer authored
    - now takes parameters for rays as function input instead of using member variables
    d44525ab
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SimulationEngineTest.cpp 4.62 KiB
    /*
     * ----------------------------------------------------------------
     *
     *		ITA geometrical acoustics
     *		(c) Copyright Institute of Technical Acoustics (ITA)
     *		RWTH Aachen University, Germany, 2015-2019
     *
     * ----------------------------------------------------------------
     *				    ____  __________  _______
     *				   //  / //__   ___/ //  _   |
     *				  //  /    //  /    //  /_|  |
     *				 //  /    //  /    //  ___   |
     *				//__/    //__/    //__/   |__|
     *
     * ----------------------------------------------------------------
     *
     * Tests the image (source) model algorithm.
     *
     */
    
    //#include <ITAStopWatch.h>
    //#include <ITAStringUtils.h>
    
    #include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
    #include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.h>
    #include <ITAPropagationPathSim/AtmosphericRayTracing/ODESolver/ODESolver.h>
    
    #include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
    #include <ITAPropagationPathSim/AtmosphericRayTracing/Export/ITAGeo.h>
    #include <ITAGeo/Base.h>
    
    //#include <cassert>
    
    #include <vector>
    #include <stdio.h>
    #include <math.h>
    
    using namespace std;
    using namespace ITAGeo;
    using namespace ITAPropagationPathSim::AtmosphericRayTracing;
    using namespace ITAPropagationPathSim::AtmosphericRayTracing::Simulation;
    
    void runTest(const CStratifiedAtmosphere& atmosphere, const double& sourceAltitude, const VistaVector3D& rayDirection, const string& fileSuffix)
    {
        double tMax = 10;
        auto engine = Simulation::CEngine(CAbortAtMaxTime(tMax));
        double dt = 0.01;
    
        engine.settings.adaptiveIntegration.bActive = true;
        engine.settings.adaptiveIntegration.dMaxError = 0.015;
        engine.settings.adaptiveIntegration.dUncriticalError = 0.005;
        engine.settings.adaptiveIntegration.iMaxAdaptationLevel = 32;// 32;
    
    
    
    
        engine.settings.dIntegrationTimeStep = dt;
        VistaVector3D sourcePosition = VistaVector3D(0, 0, sourceAltitude);
    
        cout << fileSuffix << ":" << endl;
        cout << "Starting Simulation-Engine..." << endl;
        engine.settings.solverMethod = Simulation::EULER;
        std::vector<std::shared_ptr<CRay>> resultEuler = engine.Run(atmosphere, sourcePosition, { rayDirection });
        engine.settings.solverMethod = Simulation::RUNGE_KUTTA;
        std::vector<std::shared_ptr<CRay>> resultRunge = engine.Run(atmosphere, sourcePosition, { rayDirection });
        cout << "Starting export..." << endl;
    
        Export::ToPropagationPath(*resultEuler[0]).Store("SimulationEngineTest_Euler_" + fileSuffix + ".json");
        Export::ToPropagationPath(*resultRunge[0]).Store("SimulationEngineTest_RungeKutta_" + fileSuffix + ".json");
        cout << "Finished" << endl << endl;
    }
    
    void TestHomogeneousAtmosphere(const double& sourceAltitude, const VistaVector3D& rayDirection, const string& fileSuffix)
    {
        auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(50);
        auto tempProfile = std::make_unique<TemperatureProfiles::CRoom>();
        auto windProfile = std::make_unique<WindProfiles::CZero>();
        auto homogeneousAtmosphere = CStratifiedAtmosphere(std::move(tempProfile), std::move(windProfile), std::move(humidProfile));
    
        runTest(homogeneousAtmosphere, sourceAltitude, rayDirection, fileSuffix);
    }
    
    void TestInhomogeneousAtmosphere(const double& sourceAltitude, const VistaVector3D& rayDirection, const string& fileSuffix)
    {
        auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(50);
        auto tempProfile = std::make_unique<TemperatureProfiles::CISA>();
        auto windProfile = std::make_unique<WindProfiles::CLog>(0.6, 0.1, VistaVector3D(1, 0, 0));
        auto inhomogeneousAtmosphere = CStratifiedAtmosphere(std::move(tempProfile), std::move(windProfile), std::move(humidProfile));
    
        runTest(inhomogeneousAtmosphere, sourceAltitude, rayDirection, fileSuffix);
    }
    
    
    int main(int iNumInArgs, char* pcInArgs[])
    {
        double sourceAltitude = 1000;
        auto rayDirection = VistaVector3D(1, 0, -1).GetNormalized();
        TestHomogeneousAtmosphere(sourceAltitude, rayDirection, "HomogeneousDiagonal");
    
        sourceAltitude = 1000;
        rayDirection = VistaVector3D(1, 0, -1).GetNormalized();
        TestInhomogeneousAtmosphere(sourceAltitude, rayDirection, "InhomogeneousDiagonal");
    
        sourceAltitude = 1000;
        rayDirection = VistaVector3D(0, 0, -1).GetNormalized();
        TestInhomogeneousAtmosphere(sourceAltitude, rayDirection, "InhomogeneousDownward");
    
        sourceAltitude = 50;
        rayDirection = VistaVector3D(1, 0, 0).GetNormalized();
        TestInhomogeneousAtmosphere(sourceAltitude, rayDirection, "Multi-Reflection");
    
        sourceAltitude = 50;
        const double theta = 101;
        rayDirection = VistaVector3D(-sin(theta / 180.0 * M_PI), 0, cos(theta /180.0*M_PI));
        TestInhomogeneousAtmosphere(sourceAltitude, rayDirection, "Upwind");
    }