Skip to content

Commit 613f38f

Browse files
Piyush ShardaPiyush Sharda
Piyush Sharda
authored and
Piyush Sharda
committed
create and call a function in networks to balance charge
1 parent 8cd2302 commit 613f38f

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

networks/metal_chem/actual_network.H

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <fundamental_constants.H>
1010
#include <network_properties.H>
11+
#include <burn_type.H>
1112

1213
using namespace amrex;
1314

@@ -32,4 +33,7 @@ namespace Rates
3233

3334
}
3435

36+
37+
void balance_charge(burn_t& state);
38+
3539
#endif

networks/metal_chem/actual_network_data.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <actual_network.H>
22

3-
43
namespace network
54
{
65

@@ -61,4 +60,14 @@ void actual_network_init()
6160
}
6261

6362
}
63+
}
64+
65+
void balance_charge(burn_t& state)
66+
{
67+
68+
// update the number density of electrons due to charge conservation
69+
state.xn[2] = -state.xn[5] - state.xn[9] + state.xn[3] + state.xn[6] + state.xn[8] +
70+
2.0 * state.xn[13] + state.xn[11] + state.xn[14] + state.xn[16] + state.xn[21] +
71+
state.xn[24] + state.xn[26] + state.xn[28] + state.xn[29] + state.xn[31];
72+
6473
}

unit_test/burn_cell_metal_chem/burn_cell.H

+3-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <eos.H>
99
#include <extern_parameters.H>
1010
#include <network.H>
11+
#include <actual_network.H>
1112

1213
amrex::Real grav_constant = C::Gconst;
1314

@@ -237,9 +238,6 @@ auto burn_cell_c() -> int {
237238
// scale the density
238239
dd += dt * (dd / tff);
239240

240-
//std::cout << "step params " << dd << ", " << tff << ", " << tff_reduc << ", " << rhotmp << ", " << state.xn << std::endl;
241-
//std::cout << "old " << dd - dt * (dd / tff) << ", delta " << dt * (dd / tff) << ", new " << dd << std::endl;
242-
243241
// stop the test if dt is very small
244242
if (dt < 10) {
245243
break;
@@ -257,9 +255,7 @@ auto burn_cell_c() -> int {
257255
}
258256

259257
// update the number density of electrons due to charge conservation
260-
state.xn[2] = -state.xn[5] - state.xn[9] + state.xn[3] + state.xn[6] + state.xn[8] +
261-
2.0 * state.xn[13] + state.xn[11] + state.xn[14] + state.xn[16] + state.xn[21] +
262-
state.xn[24] + state.xn[26] + state.xn[28] + state.xn[29] + state.xn[31];
258+
balance_charge(state);
263259

264260
// input the scaled density in burn state
265261
rhotmp = 0.0_rt;
@@ -277,8 +273,6 @@ auto burn_cell_c() -> int {
277273
// do the actual integration
278274
burner(state, dt);
279275

280-
//std::cout << "after burn: " << state << std::endl;
281-
282276
// ensure positivity and normalize
283277
//amrex::Real inmfracs[NumSpec] = {-1.0};
284278
//amrex::Real insum = 0.0_rt;
@@ -295,11 +289,7 @@ auto burn_cell_c() -> int {
295289
//}
296290

297291
// update the number density of electrons due to charge conservation
298-
state.xn[2] = -state.xn[5] - state.xn[9] + state.xn[3] + state.xn[6] + state.xn[8] +
299-
2.0 * state.xn[13] + state.xn[11] + state.xn[14] + state.xn[16] + state.xn[21] +
300-
state.xn[24] + state.xn[26] + state.xn[28] + state.xn[29] + state.xn[31];
301-
302-
//std::cout << "conserved elec: " << state.xn[2] << std::endl;
292+
balance_charge(state);
303293

304294
// reconserve mass fractions post charge conservation
305295
//insum = 0;

0 commit comments

Comments
 (0)