🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ast::IrbemAPI类 参考

#include <IrbemAPI.hpp>

Public 类型

enum  FuncIndex {
  kIrbemFortranVersion , kGetIrbemNtimeMax , kMakeLstar , kGetField ,
  kFlyInAfrlCrres , kGetCrresFlux , kNumFunctions
}
 
using FuncArray = std::array<void*, kNumFunctions>
 

Public 成员函数

 IrbemAPI (bool shouldLoad)
 
errc_t load (StringView libPath)
 
errc_t tryload (const std::vector< std::string > &libPaths)
 
errc_t unload ()
 
bool isLoaded () const
 
errc_t irbem_fortran_version1 (int *version)
 
errc_t get_irbem_ntime_max1 (int *ntime_max)
 
errc_t make_lstar1 (int ntime, int kext, const std::array< int, 5 > &options, int sysaxes, const int *iyear, const int *idoy, const double *UT, const double *x1, const double *x2, const double *x3, const double *maginput, double *Lm, double *Lstar, double *Blocal, double *Bmin, double *J, double *MLT)
 
errc_t get_field1 (int kext, const std::array< int, 5 > &options, int sysaxes, int iyear, int idoy, double UT, double x1, double x2, double x3, const double *maginput, double Bgeo[3], double &B)
 
errc_t fly_in_afrl_crres1 (int ntime, int sysaxes, int whichm, int whatf, int nene, const double *energy, const int *iyear, const int *idoy, const double *UT, const double *x1, const double *x2, const double *x3, const double *Ap15, double *flux, StringView ascii_path)
 
errc_t get_crres_flux (int ntime, int whichm, int whatf, int nene, const double *energy, const double *BBo, const double *L, const double *Ap15, double *flux, StringView ascii_path)
 

静态 Public 成员函数

static IrbemAPIInstance ()
 

Protected 成员函数

 A_DISABLE_COPY (IrbemAPI)
 

Protected 属性

void * library_ {nullptr}
 
FuncArray functions_ {}
 
std::mutex mutex_ {}
 

详细描述

IRBEM API 包装类

处理 IRBEM 共享库的动态加载、卸载与函数调用。 采用凤凰单例模式,确保在静态析构后仍可安全重建。

警告
IRBEM 库内部使用 Fortran COMMON 块(全局可变状态), 涉及 COMMON 块的方法内部加锁保护,不可重入。

构造及析构函数说明

◆ IrbemAPI()

ast::IrbemAPI::IrbemAPI ( bool shouldLoad)
explicit
参数
shouldLoad是否在构造时自动加载默认库

成员函数说明

◆ fly_in_afrl_crres1()

errc_t ast::IrbemAPI::fly_in_afrl_crres1 ( int ntime,
int sysaxes,
int whichm,
int whatf,
int nene,
const double * energy,
const int * iyear,
const int * idoy,
const double * UT,
const double * x1,
const double * x2,
const double * x3,
const double * Ap15,
double * flux,
StringView ascii_path )

沿轨道在 AFRL CRRES 辐射带模型中飞行计算通量

内部根据位置自动计算 L 和 B/B₀(调用 calcul_Lstar_opt), 然后调用 get_crres_flux 完成通量插值。共享 CRRES COMMON 块。

参数
[in]ntime要计算的时间点数量
[in]sysaxes输入坐标系统: 1 = GEO(地理) 2 = GSE(地心太阳黄道) 3 = GSM(地心太阳磁层) 4 = SM (太阳磁层) 5 = GEI(地心赤道惯性)
[in]whichm模型选择: 1 = CRRESPRO Quiet(质子,宁静期) 2 = CRRESPRO Active(质子,活跃期) 3 = CRRESELE Average(电子,平均) 4 = CRRESELE Worst Case(电子,最劣情况) 5 = CRRESELE + Ap15 分段(电子,按地磁活动分 6 档)
[in]whatf通量类型: 1 = 微分通量, 2 = 能段通量, 3 = 积分通量
[in]nene要计算的能量通道数
[in]energy能量数组 (MeV),维度 [2, nene]: energy[0][i] = 通道 i 的下界能量 energy[1][i] = 通道 i 的上界能量(whatf=1 时与下界相同)
[in]iyear年份数组(公元纪年),长度 ntime
[in]idoy年积日数组(1-366),长度 ntime
[in]UT世界时数组 [小时],长度 ntime
[in]x1,x2,x3输入坐标数组,长度 ntime
[in]Ap15前 15 天 Ap 指数平均值数组,长度 ntime
[in]ascii_path数据文件目录路径
[out]flux输出通量数组,维度 [ntime, 25] 微分通量 (whatf=1) 单位: MeV⁻¹ cm⁻² s⁻¹ 能段/积分通量 (whatf=2,3) 单位: cm⁻² s⁻¹ 超出有效范围的点赋值为 baddata

◆ get_crres_flux()

errc_t ast::IrbemAPI::get_crres_flux ( int ntime,
int whichm,
int whatf,
int nene,
const double * energy,
const double * BBo,
const double * L,
const double * Ap15,
double * flux,
StringView ascii_path )

根据 B/B₀ 和 L 值直接计算 CRRES 辐射带通量

不进行位置→L 转换,直接由 B/B₀ 和 L 在对数空间内插值计算通量。 内部按需调用 Init_CRRES 从数据文件加载模型系数。

参数
[in]ntime要计算的时间点数量
[in]whichm模型选择: 1 = CRRESPRO Quiet(质子,宁静期) 2 = CRRESPRO Active(质子,活跃期) 3 = CRRESELE Average(电子,平均) 4 = CRRESELE Worst Case(电子,最劣情况) 5 = CRRESELE + Ap15 分段(电子,按地磁活动分 6 档)
[in]whatf通量类型: 1 = 微分通量, 2 = 能段通量, 3 = 积分通量
[in]nene要计算的能量通道数
[in]energy能量数组 (MeV),维度 [2, nene]
[in]BBoB_local/B_equator 数组,长度 ntime
[in]LMcIlwain L-shell 数组,长度 ntime
[in]Ap15前 15 天 Ap 指数平均值数组,长度 ntime
[in]ascii_path数据文件目录路径
[out]flux输出通量数组,维度 [ntime, 25] 微分通量 (whatf=1) 单位: MeV⁻¹ cm⁻² s⁻¹ 能段/积分通量 (whatf=2,3) 单位: cm⁻² s⁻¹ 超出有效范围的点赋值为 baddata

◆ get_field1()

errc_t ast::IrbemAPI::get_field1 ( int kext,
const std::array< int, 5 > & options,
int sysaxes,
int iyear,
int idoy,
double UT,
double x1,
double x2,
double x3,
const double * maginput,
double Bgeo[3],
double & B )

计算空间中某点的地磁场矢量与强度(单点版本)

使用 IGRF 内源场和所选外部场模型,计算指定位置的地磁场。 内部共享 IGRF COMMON 块状态。

参数
[in]kext外部磁场模型选择(=0 仅 IGRF 内源场)
[in]options计算选项数组(长度 5)
[in]sysaxes输入坐标系统(1=GEO, 2=GSE, 3=GSM, 4=SM, 5=GEI)
[in]iyear年份(公元纪年)
[in]idoy年积日 (1-366)
[in]UT世界时 [小时]
[in]x1,x2,x3输入位置坐标
[in]maginput磁场模型输入参数数组(长度 25)
[out]BgeoGEO 坐标系下的磁场三分量 [nT](长度为 3)
[out]B磁场总强度 [nT]

◆ get_irbem_ntime_max1()

errc_t ast::IrbemAPI::get_irbem_ntime_max1 ( int * ntime_max)

获取数组的最大时间维度

返回 IRBEM 库内部所有时间数组的最大长度 (ntime_max), 由 ntime_max.inc 在编译时确定。

参数
[out]ntime_max最大时间点数

◆ irbem_fortran_version1()

errc_t ast::IrbemAPI::irbem_fortran_version1 ( int * version)

获取 IRBEM 库的 Fortran 源码版本号

返回 Makefile 构建时由 git rev-list –count 生成的版本号。

参数
[out]version版本号

◆ load()

errc_t ast::IrbemAPI::load ( StringView libPath)

加载指定路径的 IRBEM 共享库

参数
libPath库路径(不含后缀)
返回
错误码

◆ make_lstar1()

errc_t ast::IrbemAPI::make_lstar1 ( int ntime,
int kext,
const std::array< int, 5 > & options,
int sysaxes,
const int * iyear,
const int * idoy,
const double * UT,
const double * x1,
const double * x2,
const double * x3,
const double * maginput,
double * Lm,
double * Lstar,
double * Blocal,
double * Bmin,
double * J,
double * MLT )

计算 L* 及相关磁壳参数

根据给定的位置和时间,使用指定的内外磁场模型计算磁壳参数。 内部调用 IGRF 和外部场模型,共享 COMMON 块状态。

参数
[in]ntime时间点数量
[in]kext外部磁场模型选择(0-14,=0 仅 IGRF 内源场)
[in]options计算选项数组(长度 5) options(1): L* 计算方法 options(2): 磁力线追踪步长控制 options(3): 积分步数上限 options(4): 收敛判据 options(5): 保留
[in]sysaxes输入坐标系统(1=GEO, 2=GSE, 3=GSM, 4=SM, 5=GEI)
[in]iyear年份数组(公元纪年),长度 ntime
[in]idoy年积日数组(1-366),长度 ntime
[in]UT世界时数组 [小时],长度 ntime
[in]x1,x2,x3输入位置坐标数组,长度 ntime
[in]maginput磁场模型输入参数数组(长度 25 × ntime),包含太阳风动压、 Dst 指数、IMF By/Bz 等外部场模型所需参数
[out]LmMcIlwain L-shell,长度 ntime
[out]LstarRoederer L* 参数,长度 ntime
[out]Blocal当地磁场强度 [nT],长度 ntime
[out]Bmin磁赤道最小磁场强度 [nT],长度 ntime
[out]J第二绝热不变量 [Re² nT⁰·⁵],长度 ntime
[out]MLT磁地方时 [小时],长度 ntime

◆ tryload()

errc_t ast::IrbemAPI::tryload ( const std::vector< std::string > & libPaths)

尝试从多个路径加载,直到成功

参数
libPaths候选库路径列表
返回
错误码

该类的文档由以下文件生成: