/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * Geophysical Computational Tools & Library (GCTL) * * Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn) * * GCTL is distributed under a dual licensing scheme. You can redistribute * it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either version 2 * of the License, or (at your option) any later version. You should have * received a copy of the GNU Lesser General Public License along with this * program. If not, see . * * If the terms and conditions of the LGPL v.2. would prevent you from using * the GCTL, please consider the option to obtain a commercial license for a * fee. These licenses are offered by the GCTL's original author. As a rule, * licenses are provided "as-is", unlimited in time for a one time fee. Please * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget * to include some description of your company and the realm of its activities. * Also add information on how to contact you by electronic and paper mail. ******************************************************/ #include "gctl/maths/legendre.h" #include "magnetometric.h" double gctl::mmr_hemisphere_bz(double x, double y, double cx, double cy, double I, double hx, double hy, double hr, double cndt, double bkg_cndt, size_t order) { if (hr <= 0) { throw gctl::runtime_error("Invalid depression radius. From gctl::mmr_hemisphere_bz(...)"); } double d = sqrt((cx - hx)*(cx - hx) + (cy - hy)*(cy - hy)); double r = sqrt((x - hx)*(x - hx) + (y - hy)*(y - hy)); double l = sqrt((cx - x)*(cx - x) + (cy - y)*(cy - y)); double ct = (d*d + r*r - l*l)/(2.0*d*r); double rho = 1.0/cndt; double bkg_rho = 1.0/bkg_cndt; //double st = sqrt(1.0 - ct*ct); //if ((x - hx)*(cy - hy) - (cx - hx)*(y - hy) < 0) st *= -1.0; double st = ((x - hx)*(cy - hy) - (cx - hx)*(y - hy))/(r*d); double Cn, Bz = 0.0; if (r <= GCTL_ZERO) { return 0.0; } else if (d > hr) { if (r <= hr) { for (size_t i = 1; i <= order; i++) { Cn = (rho - bkg_rho)/((i+1)*rho + i*bkg_rho); Bz += Cn*pow(r/d, i+1)*gctl::legendre_polynomials(i, ct, true); } } else { for (size_t i = 1; i <= order; i++) { Cn = (rho - bkg_rho)/((i+1)*rho + i*bkg_rho); Bz += Cn*pow(hr/r, i)*pow(hr/d, i+1)*gctl::legendre_polynomials(i, ct, true); } } } else { if (r <= hr) { for (size_t i = 1; i <= order; i++) { Cn = (rho - bkg_rho)/((i+1)*rho + i*bkg_rho); Bz += Cn*pow(r/hr, i+1)*pow(d/hr, i)*gctl::legendre_polynomials(i, ct, true); } } else { for (size_t i = 1; i <= order; i++) { Cn = (rho - bkg_rho)/((i+1)*rho + i*bkg_rho); Bz += Cn*pow(d/r, i)*gctl::legendre_polynomials(i, ct, true); } } } Bz *= GCTL_MU0*I*st/(4.0*GCTL_Pi*r); // 转换为z轴朝上的坐标体系 -1 * -1 return Bz; }