fixed math, improved display

This commit is contained in:
Jay Robson 2024-01-15 12:45:22 +11:00
parent a30687306b
commit 4b018437e3
6 changed files with 16 additions and 6 deletions

View File

@ -49,8 +49,14 @@ int main()
for(int x = 0; x < reactor.width; x++)
for(int y = 0; y < reactor.height; y++)
{
std::stringstream ss;
sim::reactor::rod* r = reactor.rods[x][y];
if(!r->should_display())
{
continue;
}
std::stringstream ss;
ss << *r;
int px = X + (H - 1) * y;

View File

@ -17,7 +17,6 @@ class control_rod : public sim::reactor::rod
virtual void display(std::ostream& o) const;
virtual const char* get_name() const { return "Control Rod"; }
virtual bool should_display() const { return true; }
public:
@ -26,6 +25,7 @@ public:
virtual void update(double secs);
void set_reactivity(double a);
virtual bool should_display() const { return true; }
virtual bool should_select() const { return true; }
virtual void update_selected(double a);
};

View File

@ -11,10 +11,11 @@ class pipe : public sim::reactor::rod
virtual double get_k(sim::reactor::rod::val_t type) const;
virtual const char* get_name() const { return "Coolant"; }
virtual bool should_display() const { return true; }
public:
virtual bool should_display() const { return true; }
virtual void update(double secs);
};

View File

@ -15,12 +15,13 @@ class fuel_rod : public sim::reactor::rod
virtual void display(std::ostream& o) const;
virtual const char* get_name() const { return "Fuel"; }
virtual bool should_display() const { return true; }
public:
fuel_rod(double fuel, double mass);
virtual bool should_display() const { return true; }
virtual void update(double secs);
};

View File

@ -1,6 +1,8 @@
#include "rod.hpp"
#include <cmath>
using namespace sim::reactor;
double rod::get(val_t type) const
@ -15,7 +17,7 @@ void rod::add(val_t type, double v)
double rod::extract(val_t type, double k, double o)
{
double v = k * get_k(type) * 0.5 * (get(type) - o);
double v = (1 - std::pow(0.5, k * get_k(type))) * 0.5 * (get(type) - o);
vals_in[type] -= v;
return v;
}

View File

@ -25,6 +25,7 @@ public:
virtual double extract(val_t type, double k, double o);
virtual double get(val_t type) const;
virtual bool should_display() const { return false; }
virtual bool should_select() const { return false; }
virtual void update_selected(double a) { }
@ -53,7 +54,6 @@ protected:
virtual void display(std::ostream& o) const { };
virtual double get_k(val_t type) const { return 0; }
virtual const char* get_name() const { return "Empty"; }
virtual bool should_display() const { return false; }
void update_rod();
};