Skip to content

Commit 7013fd8

Browse files
authored
Merge pull request #159 from AetherModel/run_in_1d
Run in 1d
2 parents 4eb498b + 40306e6 commit 7013fd8

Some content is hidden

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

43 files changed

+1256
-1140
lines changed

include/inputs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ class Inputs {
156156
\param iOutput int specifying which output file type to report on
157157
**/
158158
std::string get_type_output(int iOutput);
159-
160-
161-
162159

163160
/**********************************************************************
164161
\brief returns settings["Euv"]["dt"]
@@ -488,6 +485,7 @@ class Inputs {
488485
**/
489486
std::string get_advection_neutrals_vertical();
490487
bool get_advection_neutrals_bulkwinds();
488+
bool get_advection_neutrals_implicitfriction();
491489

492490

493491
/**********************************************************************

include/neutrals.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ class Neutrals {
6060
std::vector<arma_cube> velocity_vcgc;
6161
std::vector<arma_cube> newVelocity_vcgc;
6262

63-
/// Acceleration of each species (m/s^2)
63+
/// Acceleration of each species (m/s^2) due to friction term
6464
std::vector<arma_cube> acc_neutral_friction;
65+
66+
/// Coefficient for the friction term (sum of friction coefs with others)
67+
arma_cube neutral_friction_coef;
6568

6669
/// Acceleration of each species based on Eddy contribution.
6770
/// Only in vertical direction.
@@ -515,7 +518,6 @@ class Neutrals {
515518
\param grid The grid to define the neutrals on
516519
\param time contains information about the current time
517520
**/
518-
519521
void solver_vertical_rusanov(Grid grid,
520522
Times time);
521523

@@ -524,14 +526,29 @@ class Neutrals {
524526
\param grid The grid to define the neutrals on
525527
\param time contains information about the current time
526528
**/
527-
528529
bool advect_vertical(Grid grid, Times time);
529530

531+
/**********************************************************************
532+
\brief Calculate the neutral friction in one cell using an implicit solver
533+
\param iLong the longitude index
534+
\param iLat the lat index
535+
\param iAlt the altitude index
536+
\param dt time step
537+
\param vels updated velocity, which acts as a source term for the implicit solve
538+
**/
530539
arma_vec calc_friction_one_cell(int64_t iLong, int64_t iLat, int64_t iAlt,
531-
arma_vec &vels);
540+
precision_t dt, arma_vec &vels);
532541

533-
void calc_neutral_friction();
534-
542+
/**********************************************************************
543+
\brief Calculate the neutral friction in all cells (calls one_cell above)
544+
\param dt time step
545+
**/
546+
void calc_neutral_friction_implicit(precision_t dt);
547+
548+
/**********************************************************************
549+
\brief Calculate the neutral friction coefficients for semi-implicit solver
550+
**/
551+
void calc_neutral_friction_coefs();
535552
};
536553

537554
#endif // INCLUDE_NEUTRALS_H_

share/run/UA/inputs/defaults.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
"Neutrals" : {
2525
"Vertical" : "rusanov",
2626
"Horizontal" : "default",
27-
"useBulkWinds" : true},
27+
"useBulkWinds" : true,
28+
"useImplicitFriction" : true},
2829
"Ions" : {
29-
"Along" : "rusanov",
30-
"Across" : "default"} },
30+
"Along" : "rusanov",
31+
"Across" : "default"} },
3132

3233
"Student" : {
3334
"name" : "",
@@ -120,7 +121,7 @@
120121
"AuroraFile" : "UA/inputs/aurora_earth.csv",
121122
"IndicesLookupFile" : "UA/inputs/indices_lookup.json",
122123

123-
"OnmiwebFile" : [""],
124+
"OmniwebFile" : ["UA/inputs/omni_20110319.txt"],
124125

125126
"Logfile" : {
126127
"name" : ["UA/output/log_geo.txt", "UA/output/log_mag.txt"],

share/run/UA/inputs/earth.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ BC is a density that is used in the lowest boundary cell if you
2828

2929
#NEUTRALS
3030
name, mass, vibration, thermal_cond, thermal_exp, advect, BC
31-
O, 16, 5, 5.6e-4, 0.69, 1, 5.0e17
31+
O, 16, 5, 5.6e-4, 0.69, 1, 7.0e17
3232
N, 14, 5, 5.6e-4, 0.69, 1, 2.5e11
33-
O2, 32, 7, 3.6e-4, 0.69, 1, 4.0e18
34-
N2, 28, 7, 3.6e-4, 0.69, 1, 1.7e19
33+
O2, 32, 7, 3.6e-4, 0.69, 1, 2.0e18
34+
N2, 28, 7, 3.6e-4, 0.69, 1, 1.0e19
3535
NO, 30, 7, 3.6e-4, 0.69, 1, 5.4e14
3636
He, 4, 5, 5.6e-4, 0.69, 1, 1.5e14
3737
N_2D, 14, 5, 5.6e-4, 0.69, 0, 2.5e9

src/add_sources.cpp

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,63 @@ void Neutrals::add_sources(Times time, Planets planet, Grid grid) {
1919
precision_t dt = time.get_dt();
2020

2121
heating_sources_total = heating_euv_scgc
22-
+ heating_chemical_scgc
23-
+ heating_ion_friction_scgc
24-
//+ heating_ion_heat_transfer_scgc
25-
- O_cool_scgc
26-
- NO_cool_scgc;
27-
22+
+ heating_chemical_scgc
23+
+ heating_ion_friction_scgc
24+
//+ heating_ion_heat_transfer_scgc
25+
- O_cool_scgc
26+
- NO_cool_scgc;
27+
2828
// Solve the laplace equations using the source terms,
2929
// updating the neutral temperature:
3030
update_temperature(grid, time);
3131

3232
int64_t iDir, iSpec, iSpecies;
3333
double tSim = time.get_simulation_time();
34-
34+
3535
// Horizontal winds use bulk winds:
36-
if (input.get_use_coriolis())
36+
if (input.get_use_coriolis())
3737
acc_coriolis = coriolis(velocity_vcgc, planet.get_omega(), grid.geoLat_scgc);
3838

39-
/*
40-
// Vertical winds use species winds:
41-
for (iSpec = 0; iSpec < nSpeciesAdvect; iSpec++) {
42-
// Pick out the advected neutral species:
43-
species_chars & advected_neutral = species[species_to_advect[iSpec]];
44-
45-
iDir = 2;
46-
// update velocities based on acceleration:
47-
// reduce neutral friction until solver is added
48-
advected_neutral.velocity_vcgc[iDir] =
49-
advected_neutral.velocity_vcgc[iDir] +
50-
dt * (ramp * grid.cent_acc_vcgc[iDir] +
51-
ramp * acc_coriolis[iDir] +
52-
advected_neutral.acc_neutral_friction[iDir] / 4.0 +
53-
advected_neutral.acc_ion_drag[iDir] +
54-
advected_neutral.acc_eddy);
55-
}
39+
/*
40+
// Vertical winds use species winds:
41+
for (iSpec = 0; iSpec < nSpeciesAdvect; iSpec++) {
42+
// Pick out the advected neutral species:
43+
species_chars & advected_neutral = species[species_to_advect[iSpec]];
5644
57-
calc_mass_density();
58-
// Calculate bulk vertical winds:
59-
velocity_vcgc[2].zeros();
60-
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
61-
if (species[iSpecies].DoAdvect) {
62-
velocity_vcgc[2] = velocity_vcgc[2] +
63-
species[iSpecies].mass * species[iSpecies].density_scgc %
64-
species[iSpecies].velocity_vcgc[2] / rho_scgc;
45+
iDir = 2;
46+
// update velocities based on acceleration:
47+
// reduce neutral friction until solver is added
48+
advected_neutral.velocity_vcgc[iDir] =
49+
advected_neutral.velocity_vcgc[iDir] +
50+
dt * (ramp * grid.cent_acc_vcgc[iDir] +
51+
ramp * acc_coriolis[iDir] +
52+
advected_neutral.acc_neutral_friction[iDir] / 4.0 +
53+
advected_neutral.acc_ion_drag[iDir] +
54+
advected_neutral.acc_eddy);
6555
}
66-
67-
*/
56+
57+
calc_mass_density();
58+
// Calculate bulk vertical winds:
59+
velocity_vcgc[2].zeros();
60+
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
61+
if (species[iSpecies].DoAdvect) {
62+
velocity_vcgc[2] = velocity_vcgc[2] +
63+
species[iSpecies].mass * species[iSpecies].density_scgc %
64+
species[iSpecies].velocity_vcgc[2] / rho_scgc;
65+
}
66+
67+
*/
6868

6969
// Add Velocity sources to bulk winds:
7070
for (iDir = 0; iDir < 2; iDir++) {
7171
velocity_vcgc[iDir] =
7272
velocity_vcgc[iDir] + dt * (
73-
grid.cent_acc_vcgc[iDir] +
74-
acc_coriolis[iDir] +
75-
acc_ion_collisions[iDir]);
73+
grid.cent_acc_vcgc[iDir] +
74+
acc_coriolis[iDir] +
75+
acc_ion_collisions[iDir]);
7676
acc_sources_total[iDir].zeros();
7777
}
78+
7879
// Apply Viscosity:
7980
update_horizontal_velocity(grid, time);
8081

@@ -83,17 +84,17 @@ void Neutrals::add_sources(Times time, Planets planet, Grid grid) {
8384
for (iDir = 0; iDir < 2; iDir++)
8485
species[iSpecies].velocity_vcgc[iDir] = velocity_vcgc[iDir];
8586

86-
/*
87+
/*
8788
// If we only consider the bulk winds in the horizontal direction:
8889
if (input.get_advection_neutrals_bulkwinds()) {
8990
// Calculate Coriolis:
90-
if (input.get_use_coriolis())
91+
if (input.get_use_coriolis())
9192
acc_coriolis = coriolis(velocity_vcgc, planet.get_omega(), grid.geoLat_scgc);
9293
// Add Velocity sources to bulk winds:
9394
for (int iDir = 0; iDir < 3; iDir++) {
9495
velocity_vcgc[iDir] = velocity_vcgc[iDir] + dt * (
9596
grid.cent_acc_vcgc[iDir] +
96-
acc_coriolis[iDir] +
97+
acc_coriolis[iDir] +
9798
acc_ion_collisions[iDir]);
9899
acc_sources_total[iDir].zeros();
99100
}
@@ -104,18 +105,18 @@ void Neutrals::add_sources(Times time, Planets planet, Grid grid) {
104105
// Pick out the advected neutral species:
105106
species_chars & advected_neutral = species[species_to_advect[iSpec]];
106107
// Calculate Coriolis:
107-
if (input.get_use_coriolis())
108-
acc_coriolis = coriolis(advected_neutral.velocity_vcgc,
109-
planet.get_omega(),
108+
if (input.get_use_coriolis())
109+
acc_coriolis = coriolis(advected_neutral.velocity_vcgc,
110+
planet.get_omega(),
110111
grid.geoLat_scgc);
111112
112113
for (int iDir = 0; iDir < 2; iDir++) {
113114
// update velocities based on acceleration:
114115
// reduce neutral friction until solver is added
115116
advected_neutral.velocity_vcgc[iDir] =
116117
advected_neutral.velocity_vcgc[iDir] +
117-
dt * (grid.cent_acc_vcgc[iDir] +
118-
acc_coriolis[iDir] +
118+
dt * (grid.cent_acc_vcgc[iDir] +
119+
acc_coriolis[iDir] +
119120
advected_neutral.acc_neutral_friction[iDir] / 4.0 +
120121
advected_neutral.acc_ion_drag[iDir]);
121122
// eddy acceleration is only in the vertical direction:

src/advance.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool advance(Planets &planet,
5656
neutrals.calc_bulk_velocity();
5757
neutrals.calc_kappa_eddy();
5858
neutrals.calc_viscosity();
59-
//neutrals.calc_cMax();
59+
neutrals.calc_cMax();
6060

6161
ions.fill_electrons();
6262
ions.calc_sound_speed();
@@ -65,7 +65,7 @@ bool advance(Planets &planet,
6565
precision_t dtNeutral = calc_dt(gGrid, neutrals.cMax_vcgc);
6666
precision_t dtIon = calc_dt(gGrid, ions.cMax_vcgc);
6767
time.calc_dt(dtNeutral, dtIon);
68-
68+
6969
neutralsMag.calc_mass_density();
7070
neutralsMag.calc_mean_major_mass();
7171
neutralsMag.calc_specific_heat();
@@ -85,21 +85,23 @@ bool advance(Planets &planet,
8585
neutralsMag.calc_scale_height(mGrid);
8686

8787
if (didWork)
88-
didWork = neutrals.set_bcs(gGrid, time, indices);
88+
didWork = neutrals.set_bcs(gGrid, time, indices);
89+
8990
if (didWork)
9091
didWork = ions.set_bcs(gGrid, time, indices);
92+
9193
if (didWork)
9294
didWork = neutralsMag.set_bcs(mGrid, time, indices);
9395

9496
if (gGrid.get_nAlts(false) > 1)
9597
neutrals.advect_vertical(gGrid, time);
9698

9799
neutrals.exchange_old(gGrid);
98-
//advect(gGrid, time, neutrals);
100+
advect(gGrid, time, neutrals);
99101

100102
if (didWork & input.get_check_for_nans())
101103
didWork = neutrals.check_for_nonfinites("After Horizontal Advection");
102-
104+
103105
// ------------------------------------
104106
// Calculate source terms next:
105107

@@ -111,6 +113,7 @@ bool advance(Planets &planet,
111113
neutrals,
112114
ions,
113115
indices);
116+
114117
if (didWork)
115118
didWork = calc_euv(planet,
116119
mGrid,
@@ -126,6 +129,7 @@ bool advance(Planets &planet,
126129
time,
127130
indices,
128131
ions);
132+
129133
if (didWork)
130134
didWork = electrodynamics.update(planet,
131135
mGrid,
@@ -154,8 +158,10 @@ bool advance(Planets &planet,
154158
calc_ion_collisions(neutrals, ions);
155159

156160
neutrals.add_sources(time, planet, gGrid);
161+
157162
if (didWork & input.get_check_for_nans())
158163
didWork = neutrals.check_for_nonfinites("After Add Sources");
164+
159165
neutralsMag.add_sources(time, planet, mGrid);
160166

161167
ions.calc_ion_temperature(neutrals, gGrid, time);
@@ -180,11 +186,13 @@ bool advance(Planets &planet,
180186

181187
if (didWork)
182188
didWork = output(neutrals, ions, gGrid, time, planet);
189+
183190
if (didWork)
184191
didWork = output(neutralsMag, ionsMag, mGrid, time, planet);
185192

186193
if (didWork)
187194
didWork = logfile.write_logfile(indices, neutrals, ions, gGrid, time);
195+
188196
if (didWork)
189197
didWork = logfileMag.write_logfile(indices, neutralsMag, ionsMag, mGrid, time);
190198

src/aurora.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void calc_aurora(Grid grid,
144144
};
145145

146146
static std::vector<std::vector<precision_t>> CiArray;
147-
static bool IsFirstTime = 1;
147+
static bool IsFirstTime = true;
148148

149149
// ENERGY BINS AND DE (E in eV)
150150
static precision_t min = 100;
@@ -158,12 +158,11 @@ void calc_aurora(Grid grid,
158158

159159
if (!neutrals.auroraInitialized) {
160160
// Initialize the aurora using the auroral csv file
161+
report.print(1, "Reading aurora file");
161162
read_aurora(neutrals, ions);
162163
}
163164

164165
if (IsFirstTime) {
165-
// Initialize the aurora using the auroral csv file
166-
//read_aurora(neutrals, ions);
167166

168167
precision_t lnE;
169168

@@ -192,12 +191,10 @@ void calc_aurora(Grid grid,
192191

193192
CiArray.push_back(Ci);
194193
}
195-
196-
IsFirstTime = 0;
194+
IsFirstTime = false;
197195
}
198196

199-
if (report.test_verbose(4))
200-
std::cout << "aurora - done with init!\n";
197+
report.print(4, "aurora - done with init!");
201198

202199
arma_vec rhoH1d;
203200
arma_cube scale_height;
@@ -225,8 +222,7 @@ void calc_aurora(Grid grid,
225222
arma_vec diff_energy_flux;
226223
bool DoDebug = false;
227224

228-
if (report.test_verbose(4))
229-
std::cout << "aurora - starting main loop!\n";
225+
report.print(4, "aurora - starting main loop!");
230226

231227
// loop through each altitude and calculate ionization
232228
for (iLon = 0; iLon < nLons ; iLon++) {

0 commit comments

Comments
 (0)