Skip to content

Commit

Permalink
STY: Astyle, yo!
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjridley committed Dec 29, 2024
1 parent 09caa02 commit 1a74fe0
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 134 deletions.
5 changes: 4 additions & 1 deletion src/advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,21 @@ bool advance(Planets &planet,
// advect in the 3rd dimension (vertical), but only if we have it:
if (gGrid.get_nAlts(false) > 1) {
neutrals.advect_vertical(gGrid, time);

if (didWork & input.get_check_for_nans())
didWork = neutrals.check_for_nonfinites("After Vertical Neutral Advection");

ions.advect_vertical(gGrid, time);
}

// advect in the 1st and 2nd dimensions (horizontal), but only if
// advect in the 1st and 2nd dimensions (horizontal), but only if
// we have those dimensions:
if (gGrid.get_HasXdim() || gGrid.get_HasYdim()) {
neutrals.exchange_old(gGrid);
ions.exchange_old(gGrid);
advect(gGrid, time, neutrals);
}

if (didWork & input.get_check_for_nans()) {
didWork = neutrals.check_for_nonfinites("Geo Grid: After Horizontal Advection");
didWork = neutralsMag.check_for_nonfinites("Ion Grid: After Horizontal Advection");
Expand Down
8 changes: 5 additions & 3 deletions src/aurora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ void calc_aurora(Grid grid,

CiArray.push_back(Ci);
}

IsFirstTime = false;
report.print(4, "aurora - done with init!");
}
Expand Down Expand Up @@ -229,7 +230,7 @@ void calc_aurora(Grid grid,
// loop through each altitude and calculate ionization
for (iLon = nGcs; iLon < nLons - nGcs; iLon++) {
for (iLat = nGcs; iLat < nLats - nGcs ; iLat++) {

// CHANGE
eflux = ions.eflux(iLon, iLat); // in ergs/cm2/s
avee = ions.avee(iLon, iLat); // in keV
Expand All @@ -238,13 +239,14 @@ void calc_aurora(Grid grid,

// Step 1: Calculate the height-integrated mass density:
rhoH1d.zeros();
b1d = abs(grid.bfield_unit_vcgc[2].tube(iLon,iLat));
b1d = abs(grid.bfield_unit_vcgc[2].tube(iLon, iLat));

for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++) {
rho_tube =
neutrals.species[iSpecies].rho_alt_int_scgc.tube(iLon, iLat);
rhoH1d = rhoH1d + rho_tube / b1d;
}

// Step 2: Calculate the distribution function:
diff_num_flux = calculate_maxwellian(eflux,
avee,
Expand Down Expand Up @@ -274,7 +276,7 @@ void calc_aurora(Grid grid,

// /cm3 -> /m3
// CHANGE!!!!
ionization1d = ionization1d * pcm3topm3/100.0;
ionization1d = ionization1d * pcm3topm3 / 100.0;

// Step 5: Distribute ionization among neutrals:
// Need to figure out which species get what percentage of the
Expand Down
1 change: 1 addition & 0 deletions src/calc_euv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void calc_ionization_heating(Euv euv,
neutrals.species[iSpecies].chapman_scgc.slice(iAlt);
}
}

intensity2d = euv.wavelengths_intensity_top[iWave] * exp(-1.0 * tau2d);

for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++) {
Expand Down
13 changes: 8 additions & 5 deletions src/calc_ion_drift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ void Ions::calc_ion_drift(Neutrals neutrals,

for (iIon = 0; iIon < nSpecies; iIon++) {

for (int64_t iComp = 0; iComp < 3; iComp++) {
for (int64_t iComp = 0; iComp < 3; iComp++)
species[iIon].perp_velocity_vcgc[iComp].zeros();
}

if (species[iIon].DoAdvect) {

Expand All @@ -138,12 +137,15 @@ void Ions::calc_ion_drift(Neutrals neutrals,
grad_Pi_plus_Pe[iDim] = grad_Pi_plus_Pe[iDim] / rho;
efield_acc[iDim] = Nie % efield_vcgc[iDim] / rho;
}

// Neutral Wind Forcing:
report.print(5, "neutral winds");

for (int64_t iComp = 0; iComp < 3; iComp++)
wind_acc[iComp].zeros();

nuin_sum.zeros();

for (iNeutral = 0; iNeutral < neutrals.nSpecies; iNeutral++) {
nuin = species[iIon].nu_ion_neutral_vcgc[iNeutral];
nuin_sum = nuin_sum + species[iIon].nu_ion_neutral_vcgc[iNeutral];
Expand Down Expand Up @@ -193,9 +195,10 @@ void Ions::calc_ion_drift(Neutrals neutrals,
species[iIon].par_velocity_vcgc[iComp] =
(species[iIon].par_velocity_vcgc[iComp] + a_par[iComp] * dt) /
(1 + nuin_sum * dt);
species[iIon].par_velocity_vcgc[iComp].slice(nZ-1).zeros();
species[iIon].par_velocity_vcgc[iComp].slice(nZ-2).zeros();
species[iIon].par_velocity_vcgc[iComp].slice(nZ-3) = species[iIon].par_velocity_vcgc[iComp].slice(nZ-4);
species[iIon].par_velocity_vcgc[iComp].slice(nZ - 1).zeros();
species[iIon].par_velocity_vcgc[iComp].slice(nZ - 2).zeros();
species[iIon].par_velocity_vcgc[iComp].slice(nZ - 3) =
species[iIon].par_velocity_vcgc[iComp].slice(nZ - 4);
species[iIon].par_velocity_vcgc[iComp].clamp(-100, 100);

}
Expand Down
30 changes: 16 additions & 14 deletions src/calc_ion_temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,23 @@ void Ions::calc_ion_temperature(Neutrals neutrals, Grid grid,
front1d = 3.0 / 2.0 * cKB * density_scgc.tube(iLon, iLat);
dalt1d = grid.dalt_lower_scgc.tube(iLon, iLat);
sources1d = (heating_neutral_friction_scgc.tube(iLon, iLat) +
heating_neutral_heat_transfer_scgc.tube(iLon, iLat));
heating_neutral_heat_transfer_scgc.tube(iLon, iLat));
sources1d = sources1d / front1d;
conduction1d.zeros(); // reset temp variable to zero
conduction1d = solver_conduction(temp1d,
lambda1d,
front1d,
sources1d,
conduction1d = solver_conduction(temp1d,
lambda1d,
front1d,
sources1d,
dalt1d,
dt/10.,
nGCs,
dt / 10.,
nGCs,
false);
// The conduction solver gives Tnew-Told, so divide by dt
conduction1d.clamp(200, 5000);
temperature_scgc.tube(iLon, iLat) = conduction1d;
}
}

for (iIon = 0; iIon < nSpecies; iIon++)
species[iIon].temperature_scgc = temperature_scgc;

Expand All @@ -123,17 +124,17 @@ void Ions::calc_ion_temperature(Neutrals neutrals, Grid grid,
front1d = 3.0 / 2.0 * cKB * species[iIon].density_scgc.tube(iLon, iLat);
dalt1d = grid.dalt_lower_scgc.tube(iLon, iLat);
sources1d = (species[iIon].heating_neutral_friction_scgc.tube(iLon, iLat) +
species[iIon].heating_neutral_heat_transfer_scgc.tube(iLon, iLat));
species[iIon].heating_neutral_heat_transfer_scgc.tube(iLon, iLat));
sources1d = sources1d / front1d;

conduction1d.zeros(); // reset temp variable to zero
conduction1d = solver_conduction(temp1d,
lambda1d,
front1d,
sources1d,
conduction1d = solver_conduction(temp1d,
lambda1d,
front1d,
sources1d,
dalt1d,
dt/10.,
nGCs,
dt / 10.,
nGCs,
false);

// The conduction solver gives Tnew-Told, so divide by dt
Expand All @@ -142,6 +143,7 @@ void Ions::calc_ion_temperature(Neutrals neutrals, Grid grid,
} // Lats
} // Lons
} // Ions

tempT.zeros();
tempD.zeros();

Expand Down
14 changes: 8 additions & 6 deletions src/calc_neutral_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ void Neutrals::clamp_density() {
report.enter(function, iFunction);

int64_t iSpecies;
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++) {

for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
species[iSpecies].density_scgc.clamp(1.0, 1e32);
}

report.exit(function);
return;
Expand Down Expand Up @@ -201,6 +201,7 @@ void Neutrals::calc_bulk_velocity() {

velocity_vcgc[iDir] = velocity_vcgc[iDir] / rho_advected;
}

report.exit(function);
return;
}
Expand Down Expand Up @@ -592,10 +593,10 @@ void Neutrals::calc_chapman(Grid grid) {
integral3d.slice(iAlt) = integral3d.slice(iAlt + 1) +
species[iSpecies].density_scgc.slice(iAlt) %
grid.dr_lower_scgc.slice(iAlt + 1);
species[iSpecies].rho_alt_int_scgc.slice(iAlt) =
species[iSpecies].rho_alt_int_scgc.slice(iAlt + 1) +
species[iSpecies].density_scgc.slice(iAlt) %
grid.dalt_lower_scgc.slice(iAlt + 1);
species[iSpecies].rho_alt_int_scgc.slice(iAlt) =
species[iSpecies].rho_alt_int_scgc.slice(iAlt + 1) +
species[iSpecies].density_scgc.slice(iAlt) %
grid.dalt_lower_scgc.slice(iAlt + 1);
}

erfcy3d = (a + b * y3d) / (c + d * y3d + y3d % y3d);
Expand Down Expand Up @@ -623,6 +624,7 @@ void Neutrals::calc_chapman(Grid grid) {
erfcy1d = erfcy3d.tube(iLon, iLat);
radius1d = grid.radius_scgc.tube(iLon, iLat);
H1d = species[iSpecies].scale_height_scgc.tube(iLon, iLat);

for (iAlt = nGCs; iAlt < nAlts; iAlt++) {
// This is on the dayside:
if (sza1d(iAlt) < cPI / 2 || sza1d(iAlt) > 3 * cPI / 2) {
Expand Down
1 change: 1 addition & 0 deletions src/electrodynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ bool Electrodynamics::update(Planets planet,

if (iZ == nZs - 1) {
report.print(5, "Getting Aurora...");

if (didWork) {
ie_get_electron_diffuse_aurora(eflux2d, avee2d, &iError);

Expand Down
4 changes: 2 additions & 2 deletions src/euv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ bool Euv::euvac(Times time,
std::cout << " " << iWave << " "
<< wavelengths_short[iWave] << " "
<< wavelengths_long[iWave] << " "
<< wavelengths_intensity_1au[iWave]/1e12 << " "
<< wavelengths_intensity_1au[iWave] / 1e12 << " "
<< euvac_afac[iWave] * 100.0 << " "
<< euvac_f74113[iWave]/1e9 << " "
<< euvac_f74113[iWave] / 1e9 << " "
<< slope << "\n";
}

Expand Down
3 changes: 1 addition & 2 deletions src/exchange_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ bool Ions::exchange_old(Grid &grid) {
bool DidWork = true;
int64_t nGCs = grid.get_nGCs();

for (int iSpecies = 0; iSpecies < nSpecies; iSpecies++) {
for (int iSpecies = 0; iSpecies < nSpecies; iSpecies++)
DidWork = exchange_one_var(grid, species[iSpecies].density_scgc, false);
}

DidWork = exchange_one_var(grid, temperature_scgc, false);
DidWork = exchange_one_var(grid, electron_temperature_scgc, false);
Expand Down
Loading

0 comments on commit 1a74fe0

Please sign in to comment.