fixed math, improved display
This commit is contained in:
parent
a30687306b
commit
4b018437e3
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue