This commit is contained in:
张壹 2025-01-09 00:08:55 +08:00
parent 4b369b25ea
commit d9648a6250
5 changed files with 32767 additions and 32750 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -101,14 +101,17 @@ int main(int argc, char const *argv[]) try
array<point3dc> obsgrad;
// 正演磁分量数据
set_magcone_ren17_tolerance(1e-30);
magobser(obsgrad, top_ele, btm_ele, obsp, sus, ShortMsg);
geodsv_io fout;
fout.init_table(obsp.size(), 6);
fout.set_column_names({"rad", "lon", "lat", "Br", "Bt", "Bp"});
fout.fill_column_point3ds(obsp, "rad", "lon", "lat");
fout.fill_column_point3dc(obsgrad, "Br", "Bt", "Bp");
fout.fill_column_point3dc(obsgrad, "Br", "Bt", "Bp", 12);
fout.save_csv("data/stt/mag_obs");
system("xyz2nc -t data/stt/mag_obs.csv -g data/stt/mag_obs_ren17.nc -r 10/55/20/65 -i 0.25/0.25 -c 1,2,3,4,5 -l x,y,Br,Bt,Bp -d ','");
return 0;
}
catch (std::exception &e)

View File

@ -28,7 +28,14 @@
#include "mkernel_tricone_Ren2017.h"
#include "cmath"
#define GCTL_MAG_TETRA_TOL 1e-16
double mag_tolerance = 1e-16;
void gctl::set_magcone_ren17_tolerance(double tol)
{
if (tol > 0) mag_tolerance = tol;
else throw invalid_argument("Invalid tolerance value. From gctl::set_magcone_ren17_tolerance(...)");
return;
}
void gctl::callink_magnetic_para(array<magcone_ren17> &in_cone, array<magcone_para_ren17> &out_para, const array<point3dc> &mag_B)
{
@ -167,7 +174,7 @@ gctl::point3dc gctl::magkernel_single(const magcone_ren17 &a_ele, const point3ds
Rij0 = std::sqrt(wi0*wi0 + mij0*mij0);
part2.set(0.0, 0.0, 0.0);
if (absw > GCTL_MAG_TETRA_TOL)
if (absw > mag_tolerance)
{
beta = atan((mij0*Sij_plus)/(Rij0*Rij0 + absw*Rij_plus))
- atan((mij0*Sij_minus)/(Rij0*Rij0 + absw*Rij_minus));
@ -175,7 +182,7 @@ gctl::point3dc gctl::magkernel_single(const magcone_ren17 &a_ele, const point3ds
part2 = sig*beta*mpara->nf[f];
}
if (std::abs(Rij0) > GCTL_MAG_TETRA_TOL)
if (std::abs(Rij0) > mag_tolerance)
{
Aij = std::log((long double)(Rij_plus+Sij_plus)) - std::log((long double)(Rij_minus+Sij_minus));
}
@ -254,7 +261,7 @@ gctl::tensor gctl::magkernel_single_tensor(const magcone_ren17 &a_ele, const poi
mij0 = gctl::dot(*a_ele.fget(f, j) - oi, mpara->ne[3*f+j]);
Rij0 = std::sqrt(wi0*wi0 + mij0*mij0);
if (std::abs(Rij0) > GCTL_MAG_TETRA_TOL)
if (std::abs(Rij0) > mag_tolerance)
{
factor_n_mij = -1.0*(Sij_plus/(Rij0*Rij0*Rij_plus) - Sij_minus/(Rij0*Rij0*Rij_minus));
factor_tij = -1.0/Rij_plus + 1.0/Rij_minus;
@ -271,7 +278,7 @@ gctl::tensor gctl::magkernel_single_tensor(const magcone_ren17 &a_ele, const poi
tmp_k = gctl::kron(mpara->ne[3*f+j], grad_Aij);
k2 = k2 - tmp_k;
if (absw > GCTL_MAG_TETRA_TOL)
if (absw > mag_tolerance)
{
grad_Rij_plus = (1.0/Rij_plus)*(site - *a_ele.fget(f, (j+1)%3));
grad_Rij_minus = (1.0/Rij_minus)*(site - *a_ele.fget(f, j));
@ -298,7 +305,7 @@ gctl::tensor gctl::magkernel_single_tensor(const magcone_ren17 &a_ele, const poi
}
else
{
if (std::abs(mij0) > GCTL_MAG_TETRA_TOL)
if (std::abs(mij0) > mag_tolerance)
{
k3 += (-1.0/mij0)*(Sij_plus/Rij_plus - Sij_minus/Rij_minus);
}

View File

@ -43,6 +43,13 @@ namespace gctl
typedef type_tricone<magcone_para_ren17> magcone_ren17; ///< 带magcone_para_ren17属性的三角锥结构体
/**
* @brief Set the tolerance for calculating the magnetic parameters of tricone elements.
*
* @param tol Tolerance
*/
void set_magcone_ren17_tolerance(double tol);
/**
* @brief Calculate the magnetic parameters of given tricone elements.
*
* @param in_tet Input and output elements