Skip to content

Commit f3e7f81

Browse files
committed
BUG: Fix init_mag_grid gravity unit vector
1 parent 1f47579 commit f3e7f81

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/init_mag_grid.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
437437

438438
// all distances, so far, are in units of planet radii, turn into meters.
439439
// Except for Q, leave that dimensionless.
440-
magAlt_scgc;
441-
magAlt_Below;
442-
magAlt_Corner;
443440
magP_scgc *= planetRadius;
444441
magP_Corner *= planetRadius;
445442
magQ_Corner *= planetRadius;
@@ -484,8 +481,8 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
484481
gravity_vcgc[iV].zeros();
485482
}
486483

487-
rad_unit_vcgc[1] = cos(magLat_scgc) / pow(1 + 3 * sin(magLat_scgc), 0.5);
488-
rad_unit_vcgc[2] = -2 * sin(magLat_scgc) / pow(1 + 3 * sin(magLat_scgc), 0.5);
484+
rad_unit_vcgc[1] = cos(magLat_scgc) / pow(abs(1 + 3 * sin(magLat_scgc)), 0.5);
485+
rad_unit_vcgc[2] = -2 * sin(magLat_scgc) / pow(abs(1 + 3 * sin(magLat_scgc)), 0.5);
489486

490487
precision_t mu = planet.get_mu();
491488
gravity_vcgc[1] = mu * rad_unit_vcgc[1] % radius2i_scgc;
@@ -506,7 +503,7 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
506503
isTooLowCell = find(geoAlt_scgc <= 0.0);
507504
isPhysicalCell = find(geoAlt_scgc > 0.0);
508505
UseThisCell.elem(isTooLowCell).fill(false);
509-
506+
510507
report.print(4, "Done altitude spacing for the dipole grid.");
511508

512509
// Calculate magnetic field and magnetic coordinates:

0 commit comments

Comments
 (0)