Skip to content

Commit c4126da

Browse files
authored
Merge branch 'develop' into cet
2 parents 65e3c3a + 7aa0614 commit c4126da

Some content is hidden

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

45 files changed

+2530
-1670
lines changed

doc/internals/coordinates.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
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+
133
# Coordinates in Aether
234

335
There are a variety of coordinates in Aether. This document describes some of them.
@@ -39,3 +71,4 @@ All locations should be described in the following coordinates:
3971
- lon, lat, radius (+alt)
4072
- magnetic lon, invariant lat?
4173

74+

include/calc_grid_derived.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ arma_vec calc_bin_edges(arma_vec centers);
1616
std::vector<precision_t> calc_bin_widths(std::vector<precision_t> centers);
1717
arma_vec calc_bin_widths(arma_vec centers);
1818

19+
// ----------------------------------------------------------------------------
20+
// A helper function for mapping grids
21+
// ----------------------------------------------------------------------------
22+
bool grid_match(Grid gGrid,
23+
Grid mGrid,
24+
Quadtree gQuadtree,
25+
Quadtree mQuadtree);
26+
1927
#endif // INCLUDE_CALC_GRID_DERIVED_H_

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: 64 additions & 2 deletions
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:
@@ -152,7 +159,55 @@ class Grid
152159

153160
// dr is the radial change along the third dimension, which is
154161
// primarily needed for building a hydrostatic solution
155-
arma_cube dr_lower_scgc;
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;
156211

157212
arma_cube MeshCoefm2;
158213
arma_cube MeshCoefm1;
@@ -201,6 +256,7 @@ class Grid
201256
void set_variable_sizes();
202257

203258
bool get_IsGeoGrid();
259+
std::string get_gridtype();
204260
bool get_HasBField();
205261
void set_IsGeoGrid(bool value);
206262
void set_IsExperimental(bool value);
@@ -236,16 +292,21 @@ class Grid
236292
bool get_Is1Dy();
237293
bool get_Is1Dz();
238294

239-
void fill_grid(Planets planet);
295+
//void fill_grid(Planets planet);
240296
void correct_xy_grid(Planets planet);
241297
void calc_sza(Planets planet, Times time);
242298
void calc_gse(Planets planet, Times time);
243299
void calc_mlt();
300+
void calc_xyz(Planets planet);
244301

245302
void calc_grid_spacing(Planets planet);
246303
void calc_alt_grid_spacing();
247304
void calc_lat_grid_spacing();
248305
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();
249310

250311
void fill_grid_radius(Planets planet);
251312
void calc_rad_unit(Planets planet);
@@ -389,6 +450,7 @@ class Grid
389450
bool IsExperimental;
390451
bool IsMagGrid;
391452
bool IsDipole = false;
453+
std::string gridType;
392454

393455
int64_t nX, nLons;
394456
int64_t nY, nLats;

include/ions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class Ions {
435435
\param dir the directory to read or write from/to
436436
\param DoRead whether to read (true) or write (false)
437437
**/
438-
bool restart_file(std::string dir, bool DoRead);
438+
bool restart_file(std::string dir, std::string cGridtype, bool DoRead);
439439

440440
/**********************************************************************
441441
\brief Exchange messages between processors

include/neutrals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class Neutrals {
470470
\param dir directory to write restart files
471471
\param DoRead read the restart files if true, write if false
472472
**/
473-
bool restart_file(std::string dir, bool DoRead);
473+
bool restart_file(std::string dir, std::string cGridtype, bool DoRead);
474474

475475
/**********************************************************************
476476
\brief Exchange messages between processors

include/solvers.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ std::vector<arma_cube> calc_gradient_cubesphere(arma_cube value, Grid grid);
9191
arma_cube calc_gradient_alt_4th(arma_cube value, Grid grid);
9292
arma_mat project_onesided_alt_3rd(arma_cube value, Grid grid, int64_t iAlt);
9393

94+
// Calculate 4th-order gradients in the native coordinate system:
95+
arma_cube calc_gradient4o_i(arma_cube value, Grid grid);
96+
arma_cube calc_gradient4o_j(arma_cube value, Grid grid);
97+
arma_cube calc_gradient4o_k(arma_cube value, Grid grid);
98+
99+
// Calculate 2nd-order gradients in the native coordinate system:
100+
arma_cube calc_gradient2o_i(arma_cube value, Grid grid);
101+
arma_cube calc_gradient2o_j(arma_cube value, Grid grid);
102+
arma_cube calc_gradient2o_k(arma_cube value, Grid grid);
103+
94104
// interpolation in 1D
95105
precision_t linear_interpolation(const precision_t y0,
96106
const precision_t y1,

include/tools.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ std::string add_cmember(std::string inString);
6565

6666
void display_vector(arma_vec vec);
6767

68+
// ----------------------------------------------------------------------
69+
// Display an armadillo vector with a strong name in front
70+
// ----------------------------------------------------------------------
71+
72+
void display_vector(std::string, arma_vec vec);
73+
void display_vector(std::string, std::vector<precision_t> vec);
74+
6875
// ----------------------------------------------------------------------
6976
// synchronize a (boolean) variable across all processors
7077
// ----------------------------------------------------------------------

share/run/UA/inputs/defaults.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100

101101
"Sources" : {
102102
"Grid" : {
103-
"Centripetal" : true,
104-
"Coriolis" : true },
103+
"Coriolis" : true,
104+
"Cent_acc": true },
105105
"Neutrals" : {
106106
"NO_cool" : false,
107107
"O_cool": false },

src/advance.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,12 @@ bool advance(Planets &planet,
213213

214214
if (time.check_time_gate(input.get_dt_write_restarts())) {
215215
report.print(3, "Writing restart files");
216-
neutrals.restart_file(input.get_restartout_dir(), DoWrite);
217-
ions.restart_file(input.get_restartout_dir(), DoWrite);
216+
neutrals.restart_file(input.get_restartout_dir(), gGrid.get_gridtype(),
217+
DoWrite);
218+
neutralsMag.restart_file(input.get_restartout_dir(), mGrid.get_gridtype(),
219+
DoWrite);
220+
ions.restart_file(input.get_restartout_dir(), gGrid.get_gridtype(), DoWrite);
221+
ionsMag.restart_file(input.get_restartout_dir(), mGrid.get_gridtype(), DoWrite);
218222
time.restart_file(input.get_restartout_dir(), DoWrite);
219223
}
220224
}

0 commit comments

Comments
 (0)