Skip to content

Commit

Permalink
Merge branch 'main' into leouieda-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
leouieda authored Feb 20, 2024
2 parents 5304e39 + bb5f194 commit d6928fc
Show file tree
Hide file tree
Showing 5 changed files with 705 additions and 16 deletions.
8 changes: 2 additions & 6 deletions choclo/dipole/_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ def magnetic_field(
b_n = c_m * (
3 * dotproduct * r_n / distance**5 - magnetic_moment_north / distance**3
)
b_u = c_m * (
3 * dotproduct * r_u / distance**5 - magnetic_moment_up / distance**3
)
b_u = c_m * (3 * dotproduct * r_u / distance**5 - magnetic_moment_up / distance**3)
return b_e, b_n, b_u


Expand Down Expand Up @@ -297,9 +295,7 @@ def magnetic_n(
+ magnetic_moment_north * r_n
+ magnetic_moment_up * r_u
)
result = (
3 * dotproduct * r_n / distance**5 - magnetic_moment_north / distance**3
)
result = 3 * dotproduct * r_n / distance**5 - magnetic_moment_north / distance**3
return VACUUM_MAGNETIC_PERMEABILITY / 4 / np.pi * result


Expand Down
12 changes: 12 additions & 0 deletions choclo/point/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@
gravity_u,
gravity_uu,
)
from ._kernels import (
kernel_e,
kernel_ee,
kernel_en,
kernel_eu,
kernel_n,
kernel_nn,
kernel_nu,
kernel_pot,
kernel_u,
kernel_uu,
)
53 changes: 43 additions & 10 deletions choclo/point/_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

from ..constants import GRAVITATIONAL_CONST
from ..utils import distance_cartesian
from ._kernels import (
kernel_e,
kernel_ee,
kernel_en,
kernel_eu,
kernel_n,
kernel_nn,
kernel_nu,
kernel_pot,
kernel_u,
kernel_uu,
)


@jit(nopython=True)
Expand Down Expand Up @@ -62,7 +74,10 @@ def gravity_pot(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
return GRAVITATIONAL_CONST * mass / distance
kernel = kernel_pot(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


@jit(nopython=True)
Expand Down Expand Up @@ -119,7 +134,9 @@ def gravity_e(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = -(easting_p - easting_q) / distance**3
kernel = kernel_e(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -177,7 +194,9 @@ def gravity_n(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = -(northing_p - northing_q) / distance**3
kernel = kernel_n(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -235,7 +254,9 @@ def gravity_u(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = -(upward_p - upward_q) / distance**3
kernel = kernel_u(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -300,7 +321,9 @@ def gravity_ee(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (easting_p - easting_q) ** 2 / distance**5 - 1 / distance**3
kernel = kernel_ee(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -365,7 +388,9 @@ def gravity_nn(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (northing_p - northing_q) ** 2 / distance**5 - 1 / distance**3
kernel = kernel_nn(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -430,7 +455,9 @@ def gravity_uu(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (upward_p - upward_q) ** 2 / distance**5 - 1 / distance**3
kernel = kernel_uu(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -490,7 +517,9 @@ def gravity_en(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (easting_p - easting_q) * (northing_p - northing_q) / distance**5
kernel = kernel_en(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -550,7 +579,9 @@ def gravity_eu(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (easting_p - easting_q) * (upward_p - upward_q) / distance**5
kernel = kernel_eu(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel


Expand Down Expand Up @@ -610,5 +641,7 @@ def gravity_nu(easting_p, northing_p, upward_p, easting_q, northing_q, upward_q,
distance = distance_cartesian(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q
)
kernel = 3 * (northing_p - northing_q) * (upward_p - upward_q) / distance**5
kernel = kernel_nu(
easting_p, northing_p, upward_p, easting_q, northing_q, upward_q, distance
)
return GRAVITATIONAL_CONST * mass * kernel
Loading

0 comments on commit d6928fc

Please sign in to comment.