Skip to content

Commit 5a5204e

Browse files
committed
BUG: still issues with gravity direction
1 parent b699a5e commit 5a5204e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/init_mag_grid.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,16 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
483483
gravity_vcgc[iV].zeros();
484484
}
485485

486-
rad_unit_vcgc[1] = cos(magLat_scgc) / pow(abs(1.0 + 3.0 * sin(magLat_scgc)
486+
// Gravity should be negative in the k direction, since the grid switches directions.
487+
// j direction should switch signs when crossing the equator (+ in south, - in north)
488+
rad_unit_vcgc[1] = sign(magLat_scgc) % cos(magLat_scgc) / pow(abs(1.0 + 3.0 * sin(magLat_scgc)
487489
% sin(magLat_scgc)), 0.5);
488-
rad_unit_vcgc[2] = 2.0 * sin(magLat_scgc) / pow(abs(1.0 + 3.0 * sin(magLat_scgc)
490+
rad_unit_vcgc[2] = - 2.0 * abs(sin(magLat_scgc)) / pow(abs(1.0 + 3.0 * sin(magLat_scgc)
489491
% sin(magLat_scgc)), 0.5);
490492

491493
precision_t mu = planet.get_mu();
492-
gravity_vcgc[1] = - mu * rad_unit_vcgc[1] % radius2i_scgc;
493-
gravity_vcgc[2] = - mu * rad_unit_vcgc[2] % radius2i_scgc;
494+
gravity_vcgc[1] = mu * rad_unit_vcgc[1] % radius2i_scgc;
495+
gravity_vcgc[2] = mu * rad_unit_vcgc[2] % radius2i_scgc;
494496
gravity_potential_scgc.set_size(nX, nY, nAlts);
495497
gravity_potential_scgc.zeros();
496498

0 commit comments

Comments
 (0)