Skip to content

Commit 613d783

Browse files
authored
Merge pull request #165 from AetherModel/ion_vertical_advection
Looks good! I added one more change - removing `centripetal` from the `.json` files since we are using `cent_acc` instead.
2 parents b429fe2 + 574e4fc commit 613d783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3773
-2060
lines changed

doc/internals/coordinates.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
# Coordinate Systems
3+
4+
## GEO - Geographic coordinate system (or geodetic)
5+
- Longitude (radians) - radians east of prime meridian (0 - 2pi)
6+
- Latitude (radians) - angle between the equatorial plane and point. For oblate spheriod, this angle is not the same as the angle orthogonal to the surface of the planet and the equatorial plane.
7+
- Radius (meters) - the distance to the center of the planet (Altitude is often used instead).
8+
9+
## PCPF - Planet-centered Planet-fixed or Geocentric coordinate system
10+
- Cartesian coordinates of Geographic coordinate system in meters (X, Y, Z).
11+
- X (meters) - aligned with the equator and prime meridian
12+
- Z (meters) - aligned with rotation axis of the planet
13+
- Y (meters) - completes the right-hand coordinate system
14+
15+
## PSE - Planetary Solar Ecliptic coordinates
16+
- Cartesian coordinates tying together planet and Sun
17+
- X (meters) - points from the center of the planet to the Sun
18+
- Y (meters) - points from the center of the planet towards dusk and opposite planet's motion around the sun
19+
- Z (meters) - orthogonal to the ecliptic plane
20+
21+
## Dipole Coordinates
22+
- Longitude (radians) - radians east of the meridian that contains the north magnetic pole and north rotation axis
23+
- P (?) - Identifies the field line, related to L-shell
24+
- Q (meters?) - The distance along the field line from some reference point, related to magnetic latitude.
25+
26+
## More Dipole Coordinates
27+
- L-shell (Planetary Radii) - The distance from the planet's center at which the magnetic field encounters the dipole's equatorial plane
28+
- Magnetic Latitude (radians) - angle between the dipole's equatorial plane and the point.
29+
- Invariant Latitude (degrees) - angle between the dipole's equatorial plane and the point at which the field-line passes through a reference radius of the planet. This is constant along the field-line and is related to the L-Shell.
30+
- Magnetic Local Time (hours) - Angle between the sun, the north magnetic pole, and the point. Explicitly, this is done in PSE XY coordinates, ignoring the Z coorinate.
31+
32+
33+
# Coordinates in Aether
34+
35+
There are a variety of coordinates in Aether. This document describes some of them.
36+
37+
## Spherical Coordinates
38+
39+
The easiest coordinate system to understand within Aether is the spherical system, which is a longitude, latitude, radial (LLR) coordinate system. When the planet is a pure sphere, the LLR system is orthogonal - meaning that the grid lines up perfectly with the lines of constant longitude, latitude, and radius.
40+
41+
In Aether, longitude and latitude are expressed in radians and are positive towards the east and towards the north. Radius is expressed in meters and is positive away from the planet (upwards). In Aether, often Altitude is used instead of radius. When the planet is a perfect sphere, these are offset by a constant value.
42+
43+
If the planet is an oblate spheriod, then the equator is larger than the pole, so that the planetary radius is dependent on latitude. Aether is currently set up so that Altitude is not dependent on latitude or longitude, so that if an oblate spheriod is used, then a constant altitude would have a radius that is dependent on latitude. This means that the coordinate system is not purely orthogonal. At this time, this is not dealt with properly.
44+
45+
Because Aether considers gravity to be a function of radius and explicitly includes the centrifugal acceleration, the pertubation away from a perfect sphere should mostly cancel.
46+
47+
## i, j, k Coordinates
48+
49+
As described in the grid.md file, Aether uses a logical '(i, j, k)' 3D grid structure. Therefore, we refer to the 'primary' coordinates as the ijk coordinate system. What this means is that the i-coordinate is in the i-direction, the j-coordinate is in the j-direction, and the k-coordinate is in the k-direction.
50+
51+
For the (perfectly) spherical grid, the i-coordinate is longitude, the j-coordinate is latitude, and the k-coordinate is radius.
52+
53+
For the Cubedsphere grid, the i-coordinate is RIGHT, the j-coodinate is UP, and the k-coordinate is radius. Each face of the cubedsphere has the same coordinate system, but only with reference to that face. This means that if each face is looked at independently, the lower left corner is at (about) i = -45, j = -45 deg, while the upper right corner is at i = +45, j = +45 deg. Radius is treated the same as in a spherical grid.
54+
55+
Should the official coordinates be in the native coordinates (which could be different for each system), or should the coordinates be in meters, such that when gradients are taken, they are in /m?
56+
57+
Maybe we could have:
58+
59+
i_scgc, j_scgc, k_scgc - coordinates in the native coordinates (radians, meters, etc.)
60+
im_scgc, jm_scgc, km_scgc - coordinate in meters
61+
62+
The question is what variables do we need?
63+
64+
Locations:
65+
- Cell Centers (these are the center of each volume)
66+
- Cell Edges in the i, j, k directions (these are the center of each area)
67+
- Cell Corners
68+
69+
All locations should be described in the following coordinates:
70+
- i, j, k
71+
- lon, lat, radius (+alt)
72+
- magnetic lon, invariant lat?
73+
74+

ext/IE/EIE_IoLibrary.f90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ subroutine IO_GetPotential(PotentialOut, iError)
281281
real, dimension(IOi_NeednMLTs,IOi_NeednLats) :: ValueOut
282282
real, dimension(IOi_NeednMLTs,IOi_NeednLats), intent(out) :: PotentialOut
283283
real :: Filler = 0.0
284+
integer :: iLat, iMlt
284285

285286
iError = 0
286287

@@ -302,6 +303,27 @@ subroutine IO_GetPotential(PotentialOut, iError)
302303

303304
call IO_GetNonGridBasedPotential(ValueOut, iError)
304305

306+
! In Weimer, there are sometimes 0 potentials. I don't know why.
307+
if (maxval(abs(IOr2_NeedLats)) > 80.0) then
308+
309+
do iMlt = 2, IOi_NeednMLTs - 1
310+
do iLat = 2, IOi_NeednLats - 1
311+
if (ValueOut(iMlt, iLat) == 0.0) then
312+
if (ValueOut(iMlt, iLat - 1)*ValueOut(iMlt, iLat + 1) > 0) then
313+
! this is a "hole" in the potential, since the potential is
314+
! the same sign both above and below the current point.
315+
ValueOut(iMlt, iLat) = ( &
316+
ValueOut(iMlt - 1, iLat) + &
317+
ValueOut(iMlt, iLat - 1) + &
318+
ValueOut(iMlt + 1, iLat) + &
319+
ValueOut(iMlt, iLat + 1))/4.0
320+
endif
321+
endif
322+
enddo
323+
enddo
324+
325+
endif
326+
305327
if (iError == 0) then
306328
PotentialOut = ValueOut
307329
else

include/advance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ bool advance(Planets &planet,
4444
Chemistry &chemistry,
4545
Chemistry &chemistryMag,
4646
Electrodynamics &electrodynamics,
47+
Electrodynamics &electrodynamicsMag,
4748
Indices &indices,
4849
Logfile &logfile,
4950
Logfile &logfileMag);

include/dipole.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ namespace Dipole2 {
5959
*************************************************/
6060
namespace Dipole4 {
6161

62-
/// The normalized origins of each face of the cube (i.e. corner)
62+
/// The normalized origins of each node (i.e. corner)
6363
static const arma_mat ORIGINS = {
6464
{ 0.0, -0.5, 0.0},
6565
{ 1.0, -0.5, 0.0},
6666
{ 1.0, 0.0, 0.0},
6767
{ 0.0, 0.0, 0.0}
6868
};
6969

70-
/// Normalized right steps in cube
70+
/// Normalized right steps in node
7171
static const arma_mat RIGHTS = {
7272
{1.0, 0.0, 0.0},
7373
{1.0, 0.0, 0.0},
7474
{1.0, 0.0, 0.0},
7575
{1.0, 0.0, 0.0}
7676
};
7777

78-
/// Normalized up steps in cube
78+
/// Normalized up steps in node
7979
static const arma_mat UPS = {
8080
{0.0, 0.5, 0.0},
8181
{0.0, 0.5, 0.0},

include/grid.h

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ class Grid
6969
// These define the magnetic grid:
7070
// Armidillo Cube Versions:
7171
arma_cube magLon_scgc, magX_scgc;
72+
// The magnetic latitude and altitude need to be defined better. This should be the angle between
73+
// magnetic equator and the point, but sometimes it is invariant latitude.
7274
arma_cube magLat_scgc, magY_scgc;
75+
// This is often just the altitude....
7376
arma_cube magAlt_scgc, magZ_scgc;
77+
// Invariant latitude is the magnetic latitude that the field line hits at the lowest altitude.
78+
// This is basically the L-shell, but models want it expressed as latitude and not L-shell.
79+
arma_cube magInvLat_scgc;
80+
// This is the angle from the sun, to the magnetic pole to the point.
7481
arma_cube magLocalTime_scgc;
7582

7683
// Dipole coordinates:
@@ -143,11 +150,65 @@ class Grid
143150
arma_cube sza_scgc;
144151
arma_cube cos_sza_scgc;
145152

153+
// dalt should be the altitudinal change along the third dimension,
154+
// but is really the distance between grid points.
146155
arma_cube dalt_center_scgc;
147156
arma_cube dalt_lower_scgc;
148157
arma_cube dalt_ratio_scgc;
149158
arma_cube dalt_ratio_sq_scgc;
150159

160+
// dr is the radial change along the third dimension, which is
161+
// primarily needed for building a hydrostatic solution
162+
arma_cube dr_edge;
163+
164+
// i, j, k are the three directions, so these are the grid spacing
165+
// between the cell centers in each direction, aligned with the grid
166+
arma_cube i_center_scgc;
167+
arma_cube j_center_scgc;
168+
arma_cube k_center_scgc;
169+
170+
// edges are defined in the direction of the coordinate, shifted -half
171+
// a cell in that direction.
172+
arma_cube i_edge_scgc;
173+
arma_cube j_edge_scgc;
174+
arma_cube k_edge_scgc;
175+
176+
// corners are defined as shifted by -half a cell in each direction
177+
arma_cube i_corner_scgc;
178+
arma_cube j_corner_scgc;
179+
arma_cube k_corner_scgc;
180+
181+
// native distances in native units:
182+
arma_cube di_center_scgc;
183+
arma_cube dj_center_scgc;
184+
arma_cube dk_center_scgc;
185+
186+
// native distance in meters
187+
arma_cube di_center_m_scgc;
188+
arma_cube dj_center_m_scgc;
189+
arma_cube dk_center_m_scgc;
190+
191+
// Gradients on the edges really only have to be between cells, so they
192+
// can be defined at the interfaces (n-1 of them)
193+
arma_cube di_edge;
194+
arma_cube dj_edge;
195+
arma_cube dk_edge;
196+
// in meters:
197+
arma_cube di_edge_m;
198+
arma_cube dj_edge_m;
199+
arma_cube dk_edge_m;
200+
201+
// These are for stretched grids:
202+
arma_cube di_ratio;
203+
arma_cube di_ratio_sq;
204+
arma_cube di_one_minus_r2;
205+
arma_cube dj_ratio;
206+
arma_cube dj_ratio_sq;
207+
arma_cube dj_one_minus_r2;
208+
arma_cube dk_ratio;
209+
arma_cube dk_ratio_sq;
210+
arma_cube dk_one_minus_r2;
211+
151212
arma_cube MeshCoefm2;
152213
arma_cube MeshCoefm1;
153214
arma_cube MeshCoefp0;
@@ -195,6 +256,7 @@ class Grid
195256
void set_variable_sizes();
196257

197258
bool get_IsGeoGrid();
259+
std::string get_gridtype();
198260
bool get_HasBField();
199261
void set_IsGeoGrid(bool value);
200262
void set_IsExperimental(bool value);
@@ -230,16 +292,21 @@ class Grid
230292
bool get_Is1Dy();
231293
bool get_Is1Dz();
232294

233-
void fill_grid(Planets planet);
295+
//void fill_grid(Planets planet);
234296
void correct_xy_grid(Planets planet);
235297
void calc_sza(Planets planet, Times time);
236298
void calc_gse(Planets planet, Times time);
237299
void calc_mlt();
300+
void calc_xyz(Planets planet);
238301

239302
void calc_grid_spacing(Planets planet);
240303
void calc_alt_grid_spacing();
241304
void calc_lat_grid_spacing();
242305
void calc_long_grid_spacing();
306+
void calc_maglong_grid_spacing();
307+
void calc_i_grid_spacing();
308+
void calc_j_grid_spacing();
309+
void calc_k_grid_spacing();
243310

244311
void fill_grid_radius(Planets planet);
245312
void calc_rad_unit(Planets planet);
@@ -383,6 +450,7 @@ class Grid
383450
bool IsExperimental;
384451
bool IsMagGrid;
385452
bool IsDipole = false;
453+
std::string gridType;
386454

387455
int64_t nX, nLons;
388456
int64_t nY, nLats;

include/inputs.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,7 @@ class Inputs {
436436
bool get_O_cooling();
437437

438438
/**********************************************************************
439-
\brief returns settings["
440-
\param
441-
**/
442-
bool get_use_centripetal();
443-
444-
/**********************************************************************
445-
\brief returns settings["
439+
\brief returns settings["
446440
\param
447441
**/
448442
bool get_use_coriolis();
@@ -487,7 +481,8 @@ class Inputs {
487481
bool get_advection_neutrals_bulkwinds();
488482
bool get_advection_neutrals_implicitfriction();
489483

490-
484+
std::string get_advection_ions_along();
485+
491486
/**********************************************************************
492487
\brief returns settings["
493488
\param

0 commit comments

Comments
 (0)