Commit 5d0734dc authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files
parents 2832fcbf 72035c12
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_DIFFERENTIALEQUATIONS
#define IW_ITA_PROPAGATIONPATHSIM_DIFFERENTIALEQUATIONS
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace DifferentialEquations
{
//! This class can be used to solve the ordinary differential equations (ODEs) of ray propagation in a stratified medium
/**
* The differential equations are taken from the slowness vector approach described in:
* A. D. Pierce. Acoustics: An Introduction to Its Physical Principles and Applications, volume 20. McGraw-Hill New York, 1981.
*
* More details can be found in the Master thesis of Philipp Schäfer from 2017:
* Atmospheric Ray Tracing basen on altitude-dependent weather data
*/
class ITA_PROPAGATION_PATH_SIM_API IStratifiedAtmosphereSolver
{
public:
//! Solves the ODE for a single timestep using the Runge-Kutta (RK4) method
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
virtual void Process(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere) = 0;
protected:
//! Calculates the derivatives of the wavefront position and slowness vector
/**
* @param[in] rz Altitude of current wavefront position
* @param[in] s Current slowness vector
* @param[in] atmosphere Stratified atmosphere
* @param[out] dr New delta of wavefront position (ray movement)
* @param[out] dsz New delta of slowness vector z-component
*/
static void CalculateDerivatives(const double& rz, const VistaVector3D& s, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& dr, double& dsz);
static VistaVector3D DeltaWFPosition(const VistaVector3D& s, const double& omega, const double& c, const VistaVector3D& v);
static double DeltaSlownessZ(const VistaVector3D& s, const double& omega, const double& c, const double& dc, const VistaVector3D& dv, const int& signRZ);
};
//! This class can be used to solve the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the classical Runge-Kutta method (RK4)
/**
* Literature:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*/
class ITA_PROPAGATION_PATH_SIM_API CRungeKuttaSolver : public IStratifiedAtmosphereSolver
{
public:
CRungeKuttaSolver() {}
public:
//! Solves the ODE for a single timestep using the Runge-Kutta (RK4) method
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
void Process(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
};
//! This class can be used to solve the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the Euler method
/**
* Literature:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*/
class ITA_PROPAGATION_PATH_SIM_API CEulerSolver : public IStratifiedAtmosphereSolver
{
public:
CEulerSolver() {}
public:
//! Solves the ODE for a single timestep using the Euler method
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
void Process(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
};
class ITA_PROPAGATION_PATH_SIM_API CAdaptiveSolver : public IStratifiedAtmosphereSolver
{
private:
IStratifiedAtmosphereSolver& baseSolver;
public:
CAdaptiveSolver(CEulerSolver solver): baseSolver(solver) { }
CAdaptiveSolver(CRungeKuttaSolver solver) : baseSolver(solver) { }
CAdaptiveSolver() : CAdaptiveSolver(CRungeKuttaSolver()) {}
void Process(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_DIFFERENTIALEQUATIONS
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
#define IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch/Settings.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Settings.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
// STD
#include <vector>
#include <memory>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace EigenraySearch {
class ITA_PROPAGATION_PATH_SIM_API CEngine
{
public:
EigenraySearch::Settings eigenraySettings;
Simulation::Settings simulationSettings;
public:
CEngine() {}
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition);
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
#define IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
#include <ITAPropagationPathSim/Definitions.h>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace EigenraySearch {
struct ITA_PROPAGATION_PATH_SIM_API RayAdaptationSettings {
struct {
unsigned int maxNAdaptations = 15; //< Abort after X adaptations of the ray resolution
//double minAngleResolutionDeg = 0.001; //< []
} abort;
struct {
double maxReceiverRadius = 1; //< [m]
double maxSourceReceiverAngle = 1; //< []
double maxAngleForGeomSpreading = 0.01; //< []
} accuracy;
struct {
double threshold = 0.1; //< [0 1]
} advancedRayZooming;
};
struct ITA_PROPAGATION_PATH_SIM_API RayTracingAbortSettings {
unsigned int maxReflectionOrder = 3; //< Maximum considered order of reflections
double maxTime = 30; //< [s]
};
struct ITA_PROPAGATION_PATH_SIM_API Settings {
RayTracingAbortSettings rayTracing;
RayAdaptationSettings rayAdaptation;
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
\ No newline at end of file
# $Id:$
set( RelativeDir "include/ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch" )
set( RelativeSourceGroup "Header Files\\ITAPropagationPathSim\\AtmosphericRayTracing\\EigenraySearch" )
set( DirFiles
Settings.h
Engine.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EXPORT_TOITAGEO
#define IW_ITA_PROPAGATIONPATHSIM_ART_EXPORT_TOITAGEO
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAGeo/Base.h>
// STD
#include <memory>
#include <vector>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace Export
{
ITAGeo::CPropagationPath ToPropagationPath(const CRay& ray)
{
const std::vector<VistaVector3D> r = ray.SamplingPoints();
const std::vector<VistaVector3D> n = ray.WavefrontNormals();
const std::vector<double> t = ray.TimeStamps();
ITAGeo::CPropagationPath propagationPath;
propagationPath.push_back(std::make_shared<ITAGeo::CEmitter>(r[0]));
for (int idx = 0; idx < r.size(); idx++)
{
propagationPath.push_back(std::make_shared<ITAGeo::CInhomogeneity>(r[idx], n[idx], t[idx]));
if (ray.IsReflectionIdx(idx))
{
auto anchor = std::make_shared<ITAGeo::CSpecularReflection>(r[idx]);
anchor->v3FaceNormal = VistaVector3D(0, 0, 1);
propagationPath.push_back(anchor);
}
}
propagationPath.push_back(std::make_shared<ITAGeo::CSensor>(r[r.size()-1]));
return propagationPath;
}
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EXPORT_TOITAGEO
\ No newline at end of file
# $Id:$
set( RelativeDir "include/ITAPropagationPathSim/AtmosphericRayTracing/Export" )
set( RelativeSourceGroup "Header Files\\ITAPropagationPathSim\\AtmosphericRayTracing\\Export" )
set( DirFiles
ITAGeo.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
#define IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace ODESolver
{
//! Converts a wavefront normal to a slowness vector for given altitude in stratified atmosphere
VistaVector3D ITA_PROPAGATION_PATH_SIM_API NormalToSlowness(const VistaVector3D& n, const double& rz, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Converts a slowness vector to a wavefront normal
/**
* The wavefront normal has the same direction as the slowness vector (n = s / norm(s))
*/
VistaVector3D ITA_PROPAGATION_PATH_SIM_API SlownessToNormal(const VistaVector3D& s);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the Euler method
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
void ITA_PROPAGATION_PATH_SIM_API Euler(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the Euler method
/**
* @param[in] r Current wavefront position.
* @param[in] s Current slowness vector.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
* @param[out] rNew New wavefront position.
* @param[out] sNew New slowness vector.
*
* Literature for solver:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*
* The differential equations are taken from the slowness vector approach described in:
* A. D. Pierce. Acoustics: An Introduction to Its Physical Principles and Applications, volume 20. McGraw-Hill New York, 1981.
*/
void ITA_PROPAGATION_PATH_SIM_API Euler(const VistaVector3D& r, const VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& rNew, VistaVector3D& sNew);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the classical Runge-Kutta method (RK4)
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
void ITA_PROPAGATION_PATH_SIM_API RungeKutta(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the classical Runge-Kutta method (RK4)
/**
* @param[in] r Current wavefront position.
* @param[in] s Current slowness vector.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
* @param[out] rNew New wavefront position.
* @param[out] sNew New slowness vector.
*
* Literature for solver:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*
* The differential equations are taken from the slowness vector approach described in:
* A. D. Pierce. Acoustics: An Introduction to Its Physical Principles and Applications, volume 20. McGraw-Hill New York, 1981.
*/
void ITA_PROPAGATION_PATH_SIM_API RungeKutta(const VistaVector3D& r, const VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& rNew, VistaVector3D& sNew);
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
\ No newline at end of file
# $Id:$
set( RelativeDir "include/ITAPropagationPathSim/AtmosphericRayTracing/ODESolver" )
set( RelativeSourceGroup "Header Files\\ITAPropagationPathSim\\AtmosphericRayTracing\\ODESolver" )
set( DirFiles
ODESolver.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_SIMULATION_RAYGRID
#define IW_ITA_PROPAGATIONPATHSIM_ART_SIMULATION_RAYGRID
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
// STD
#include <vector>
#include <memory>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
class ITA_PROPAGATION_PATH_SIM_API CRayGrid
{
protected:
typedef std::shared_ptr<CRay> RayPtr;
typedef std::vector< RayPtr > RayVector;
typedef std::vector<RayVector> RayMatrix;
VistaVector3D v3SourcePos; //< Origin of all rays in this ray grid.
std::vector<double> vdThetaDeg; //< Sorted vector of elevation angles in degrees.
std::vector<double> vdPhiDeg; //< Sorted vector of azimuth angles in degrees.
RayMatrix vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
private:
RayVector vpRays; //< Vector of all rays contained by vppRayMatrix. Call InitRayVectorFromRayMatrix() if vppRayMatrix changes.
bool bCircularPhi = false; //< Indicates whether the azimuth vector is considered to be circular (phi covers full 360 degrees) or not.
private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool& circularPhi = false);
public:
CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool& circularPhi = false);
protected:
CRayGrid() {}
void InitRayVectorFromRayMatrix();
private:
int IndexToThetaIndex(const int& idx) const;
int IndexToPhiIndex(const int& idx) const;
int GetIndex(const std::shared_ptr<CRay>& pRay) const;
void GetNeighboringAngleIndices(const std::shared_ptr<CRay>& pRay, std::vector<int>& thetaIdxVec, std::vector<int>& phiIdxVec) const;
bool HasPoleDirection(const std::shared_ptr<CRay>& pRay) const;
//---GET Functions---
protected:
const std::vector<std::shared_ptr<CRay>>& ConstRayVectorReference() const { return vpRays; }
public:
std::vector<double> ThetaDeg() const { return vdThetaDeg; }
std::vector<double> PhiDeg() const { return vdPhiDeg; }
int NTheta() const { return vdThetaDeg.size(); }
int NPhi() const { return vdPhiDeg.size(); }
int NRays() const { return vpRays.size(); }
VistaVector3D SourcePosition() const { return v3SourcePos; }
std::vector<std::shared_ptr<CRay>> Rays() const { return vpRays; }
bool IsEmpty() const { return NTheta() == 0 || NPhi() == 0; }
bool Contains(std::shared_ptr<CRay> pRay) const { return std::find(vpRays.cbegin(), vpRays.cend(), pRay) == vpRays.cend(); }
//! Returns a ray grid containing the rays surrounding the given ray (including this ray).
/**
* Returns an empty ray grid if the given ray is not part of this ray grid.
*/
CRayGrid GetNeighboringRays(const std::shared_ptr<CRay>& pRay) const;
//! Sets the boundaries of this ray grid to the rays surrounding the given ray (including this ray).
/**
* If the ray is not part of this ray grid, this will be empty.
*/
void SetToNeighboringRays(const std::shared_ptr<CRay>& pRay);
//! Creates a ray grid with the same initial ray directions but new rays
CRayGrid CopyWithNewRays() const;
};
class ITA_PROPAGATION_PATH_SIM_API CEquiangularRayDistribution : public CRayGrid
{
public:
CEquiangularRayDistribution(const VistaVector3D&