tweaked parameters

This commit is contained in:
Jay Robson 2024-01-17 14:14:59 +11:00
parent 6b0b3934c5
commit ab7afb7b24
6 changed files with 95 additions and 63 deletions

View File

@ -35,15 +35,20 @@ int main()
sim::reactor::fuel::fuel_rod(2000, 4000), sim::reactor::fuel::fuel_rod(2000, 4000),
sim::reactor::control::control_rod(10000, 1), sim::reactor::control::control_rod(10000, 1),
sim::reactor::coolant::pipe(vessel), { sim::reactor::coolant::pipe(vessel), {
"# #", "# ##",
" FCF ", "#FCF ",
" C C ", " C C ",
" FCF ", " FCF#",
"# #" "## #"
}); });
double secs = 0; double secs = 0;
long clock = get_now(); long clock = get_now();
double speed = 10000;
int framerate = 100;
int extra = 100;
speed /= extra;
for(;;) for(;;)
{ {
@ -53,30 +58,36 @@ int main()
{ {
long mins = secs / 60; long mins = secs / 60;
long hours = mins / 60;
long days = hours / 24;
long years = days / 365;
double s = fmod(secs, 60); double s = fmod(secs, 60);
long hours = mins / 60;
mins %= 60; mins %= 60;
long days = hours / 24;
hours %= 24; hours %= 24;
long years = days / 365;
days %= 365; days %= 365;
ss << "Time:\n"; ss << "Time:\n";
if(years > 0) ss << years << "y "; if(years > 0) goto years;
if(days > 0) ss << days << "d "; if(days > 0) goto days;
if(hours > 0) ss << hours << "h "; if(hours > 0) goto hours;
if(mins > 0) ss << mins << "m "; if(mins > 0) goto mins;
goto secs;
ss << s << "s\n\n"; years: ss << years << "y ";
days: ss << days << "d ";
hours: ss << hours << "h ";
mins: ss << mins << "m ";
secs: ss << s << "s\n\n";
} }
reactor.update(0.01); for(int i = 0; i < extra; i++)
{
reactor.update(speed / framerate);
vessel.update(); vessel.update();
secs += 0.01; secs += speed / framerate;
}
ss << "Vessel\n" << vessel << "\n"; ss << "Vessel\n" << vessel << "\n";
@ -84,7 +95,7 @@ int main()
display::draw_text(1, 0, ss.str().c_str()); display::draw_text(1, 0, ss.str().c_str());
const int X = 1, Y = 30; const int X = 1, Y = 30;
const int W = 36, H = 10; const int W = 36, H = 11;
for(int x = 0; x < reactor.width; x++) for(int x = 0; x < reactor.width; x++)
for(int y = 0; y < reactor.height; y++) for(int y = 0; y < reactor.height; y++)
@ -141,13 +152,13 @@ int main()
long now = get_now(); long now = get_now();
while(clock + 10000 > now) while(clock + 1e6 / framerate > now)
{ {
usleep(clock + 10000 - now); usleep(clock + 1e6 / framerate - now);
now = get_now(); now = get_now();
} }
clock += 10000; clock += 1e6 / framerate;
} }
return 0; return 0;

View File

@ -11,7 +11,7 @@ pipe::pipe(coolant::vessel& v)
double pipe::get_k(val_t type) const double pipe::get_k(val_t type) const
{ {
return vessel->get_level() / vessel->get_volume(); return vessel->get_level() / vessel->get_volume() * 0.5;
} }
void pipe::update(double secs) void pipe::update(double secs)

View File

@ -33,7 +33,7 @@ double vessel::add_heat(double t1)
{ {
double t2 = get_heat(); double t2 = get_heat();
double t = t1 - t2; double t = t1 - t2;
double m1 = 1; double m1 = 1000;
double m2 = level + fluid.g_to_l(steam); double m2 = level + fluid.g_to_l(steam);
double m = m1 + m2; double m = m1 + m2;

View File

@ -13,6 +13,8 @@ void fuel_rod::display(std::ostream& o) const
o << "Fuel: " << s.get_fuel() << " / " << s.get_mass() << " mol\n"; o << "Fuel: " << s.get_fuel() << " / " << s.get_mass() << " mol\n";
o << "Efficiency: " << (s.get_efficiency() * 100) << " %\n"; o << "Efficiency: " << (s.get_efficiency() * 100) << " %\n";
o << "Energy: +" << s.get_energy() << " C\n"; o << "Energy: +" << s.get_energy() << " C\n";
o << "Iodine: " << s.get_i_135() << " mol\n";
o << "Xenon: " << s.get_xe_135() << " mol\n";
} }
double fuel_rod::get_k(val_t type) const double fuel_rod::get_k(val_t type) const

View File

@ -12,6 +12,53 @@ sample::sample(double fuel, double mass)
this->mass = mass; this->mass = mass;
} }
void sample::absorb_fast_neutrons()
{
double volume = get_volume();
double neutrons = fast_neutrons;
double neutrons_iodine = neutrons * (i_135 / volume);
double neutrons_xenon = neutrons * ((xe_135 * Xe_135_M) / volume);
double used_total = neutrons * (i_135 + xe_135 * Xe_135_M) / volume;
fast_neutrons -= used_total;
// deal with these edge cases
if(xe_135 < 0) { fast_neutrons -= xe_135; xe_135 = 0; }
if(i_135 < 0) { fast_neutrons -= i_135; i_135 = 0; }
}
void sample::absorb_slow_neutrons()
{
// absorb neutrons
double volume = get_volume();
double neutrons = slow_neutrons;
double neutrons_fuel = neutrons * (fuel / volume);
double neutrons_iodine = neutrons * (i_135 / volume);
double neutrons_xenon = neutrons * ((xe_135 * Xe_135_M) / volume);
double neutrons_total = neutrons;
slow_neutrons = 0;
xe_135 -= neutrons_xenon;
i_135 -= neutrons_iodine;
fuel -= neutrons_fuel;
// do the poison
te_135 += neutrons_fuel * (1.0 / 50.0);
xe_135 -= neutrons_xenon;
i_135 -= neutrons_iodine;
// deal with these edge cases
if(xe_135 < 0) { slow_neutrons -= xe_135; xe_135 = 0; }
if(i_135 < 0) { slow_neutrons -= i_135; i_135 = 0; }
if(fuel < 0) { slow_neutrons -= fuel; fuel = 0; }
efficiency = neutrons_fuel / neutrons_total;
// simulate fuel use
energy += neutrons_fuel;
waste.add_fissile(neutrons_fuel * 6);
}
void sample::update(double secs) void sample::update(double secs)
{ {
double m; double m;
@ -36,42 +83,8 @@ void sample::update(double secs)
te_135 *= m; te_135 *= m;
// absorb neutrons // absorb neutrons
double volume = get_volume(); slow_neutrons += NEUTRON_BG * secs;
double neutrons = slow_neutrons + NEUTRON_BG * secs; absorb_slow_neutrons();
double neutrons_fuel = neutrons * (fuel / volume);
double neutrons_iodine = neutrons * (i_135 / volume);
double neutrons_xenon = neutrons * ((xe_135 * Xe_135_M) / volume);
slow_neutrons = 0;
// deal with these edge cases
if(neutrons_fuel > fuel)
{
slow_neutrons += neutrons_fuel - fuel;
neutrons_fuel = fuel;
}
if(neutrons_xenon > xe_135)
{
slow_neutrons += neutrons_xenon - xe_135;
neutrons_xenon = xe_135;
}
if(neutrons_iodine > i_135)
{
slow_neutrons += neutrons_iodine - i_135;
neutrons_iodine = i_135;
}
// sim::reactor::fuelulate fuel use
fuel -= neutrons_fuel;
energy += neutrons_fuel;
waste.add_fissile(neutrons_fuel * 6);
// do the poison
te_135 += neutrons_fuel * (1.0 / 8.0);
xe_135 -= neutrons_xenon;
i_135 -= neutrons_iodine;
} }
double sample::extract_energy() double sample::extract_energy()

View File

@ -10,7 +10,7 @@ namespace sim::reactor::fuel
class sample class sample
{ {
constexpr static const double Xe_135_M = 1e3; constexpr static const double Xe_135_M = 1e6;
sim::reactor::fuel::waste waste; sim::reactor::fuel::waste waste;
@ -23,8 +23,11 @@ class sample
double energy = 0; double energy = 0;
double fast_neutrons = 0; double fast_neutrons = 0;
double slow_neutrons = 0; double slow_neutrons = 0;
double efficiency = 0;
void display(std::ostream& o) const; void display(std::ostream& o) const;
void absorb_fast_neutrons();
void absorb_slow_neutrons();
public: public:
@ -39,7 +42,10 @@ public:
constexpr double get_mass() const { return mass; } constexpr double get_mass() const { return mass; }
constexpr double get_energy() const { return energy; } constexpr double get_energy() const { return energy; }
constexpr double get_volume() const { return mass + xe_135 * Xe_135_M; } constexpr double get_volume() const { return mass + xe_135 * Xe_135_M; }
constexpr double get_efficiency() const { return fuel / get_volume(); } constexpr double get_efficiency() const { return efficiency; }
constexpr double get_te_135() const { return te_135; }
constexpr double get_i_135() const { return i_135; }
constexpr double get_xe_135() const { return xe_135; }
friend std::ostream& operator<<(std::ostream& o, const sample& s) friend std::ostream& operator<<(std::ostream& o, const sample& s)
{ {