2024-01-13 15:21:17 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
2024-01-25 00:35:39 +11:00
|
|
|
#include <random>
|
2024-01-25 00:52:02 +11:00
|
|
|
#include <sstream>
|
2024-01-25 00:35:39 +11:00
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "reactor/builder.hpp"
|
|
|
|
#include "reactor/control/control_rod.hpp"
|
|
|
|
#include "reactor/fuel/fuel_rod.hpp"
|
|
|
|
#include "reactor/coolant/pipe.hpp"
|
|
|
|
#include "reactor/coolant/heater.hpp"
|
|
|
|
#include "reactor/coolant/vessel.hpp"
|
|
|
|
#include "coolant/fluid_t.hpp"
|
|
|
|
#include "coolant/valve.hpp"
|
|
|
|
#include "coolant/pump.hpp"
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
#include "graphics/window.hpp"
|
2024-01-24 22:01:33 +11:00
|
|
|
#include "graphics/camera.hpp"
|
2024-01-13 15:21:17 +11:00
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
using namespace sim;
|
2024-01-13 21:54:21 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
unsigned long get_now()
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday(&tv, nullptr);
|
|
|
|
return (unsigned long)tv.tv_sec * 1000000 + tv.tv_usec;
|
|
|
|
}
|
|
|
|
|
2024-01-13 15:21:17 +11:00
|
|
|
int main()
|
|
|
|
{
|
2024-01-25 00:35:39 +11:00
|
|
|
std::random_device rd;
|
|
|
|
std::mt19937 rand(rd());
|
2024-01-18 18:00:39 +11:00
|
|
|
|
2024-01-21 19:07:38 +11:00
|
|
|
sim::reactor::coolant::vessel vessel(8, 10, 300, sim::coolant::WATER);
|
2024-01-14 17:50:43 +11:00
|
|
|
sim::reactor::reactor<5, 5> reactor = sim::reactor::builder<5, 5>(
|
2024-01-17 11:21:40 +11:00
|
|
|
sim::reactor::fuel::fuel_rod(2000, 4000),
|
2024-01-18 18:00:39 +11:00
|
|
|
sim::reactor::control::control_rod(vessel, 10000, 1),
|
2024-01-15 15:29:28 +11:00
|
|
|
sim::reactor::coolant::pipe(vessel), {
|
2024-01-18 18:00:39 +11:00
|
|
|
"#C#C#",
|
|
|
|
"CFCFC",
|
|
|
|
"#C#C#",
|
|
|
|
"CFCFC",
|
|
|
|
"#C#C#"
|
2024-01-14 17:50:43 +11:00
|
|
|
});
|
2024-01-25 00:52:02 +11:00
|
|
|
|
2024-01-18 19:41:13 +11:00
|
|
|
sim::coolant::valve<sim::reactor::coolant::vessel> valve(vessel, 1, 500);
|
|
|
|
sim::coolant::pump<sim::reactor::coolant::vessel> pump(vessel, 1e4, 15);
|
2024-01-25 00:35:39 +11:00
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
graphics::window::create();
|
2024-01-14 23:44:36 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
long clock = get_now();
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
while(!graphics::window::should_close())
|
2024-01-13 15:21:17 +11:00
|
|
|
{
|
2024-01-24 22:01:33 +11:00
|
|
|
long now = get_now();
|
|
|
|
long passed = now - clock;
|
|
|
|
double dt = (double)passed / 1e6;
|
|
|
|
clock += passed;
|
2024-01-25 00:52:02 +11:00
|
|
|
|
2024-01-14 23:44:36 +11:00
|
|
|
std::stringstream ss;
|
2024-01-15 15:29:28 +11:00
|
|
|
|
2024-01-25 00:52:02 +11:00
|
|
|
reactor.update(rand, dt);
|
|
|
|
pump.update(dt);
|
|
|
|
valve.update(dt);
|
|
|
|
vessel.update(dt);
|
2024-01-15 15:29:28 +11:00
|
|
|
|
2024-01-25 00:52:02 +11:00
|
|
|
ss << "Reactor Vessel\n\n" << vessel;
|
2024-01-24 22:01:33 +11:00
|
|
|
|
|
|
|
graphics::camera::update(dt);
|
2024-01-25 00:52:02 +11:00
|
|
|
graphics::window::loop(ss.str().c_str());
|
2024-01-13 15:21:17 +11:00
|
|
|
}
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
graphics::window::destroy();
|
2024-01-13 15:21:17 +11:00
|
|
|
}
|
|
|
|
|