diff --git a/CMakeLists.txt b/CMakeLists.txt index a7fc048..3f0422a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.25) project(FastNuclearSim VERSION 1.0) set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_FLAGS "-O3 -lncurses -I/usr/include/freetype2") +set(CMAKE_CXX_FLAGS "-g -O3 -I/usr/include/freetype2") file(GLOB_RECURSE SOURCES src/*.cpp) diff --git a/assets/model/reactor_core_joystick.stl b/assets/model/reactor_core_joystick.stl index 94a9008..9272a14 100644 Binary files a/assets/model/reactor_core_joystick.stl and b/assets/model/reactor_core_joystick.stl differ diff --git a/assets/model/turbine_valve_bypass_joystick.stl b/assets/model/turbine_valve_bypass_joystick.stl new file mode 100644 index 0000000..08e6640 Binary files /dev/null and b/assets/model/turbine_valve_bypass_joystick.stl differ diff --git a/assets/model/turbine_valve_inlet_joystick.stl b/assets/model/turbine_valve_inlet_joystick.stl new file mode 100644 index 0000000..dfe90a2 Binary files /dev/null and b/assets/model/turbine_valve_inlet_joystick.stl differ diff --git a/assets/scene-baked.glb b/assets/scene-baked.glb index 2d48ad4..5264c0c 100644 --- a/assets/scene-baked.glb +++ b/assets/scene-baked.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e8e38fa332dfb5a4b589915a2b08cad209d2b25668a86881c1fbd50e90c389bf -size 69580444 +oid sha256:8ed870c17367c0bb8858bb68fbc5277f56e47c3ffa650591b11d703e3052da9f +size 59404508 diff --git a/assets/unbaked/scene.blend b/assets/unbaked/scene.blend index e58cc31..2334421 100644 --- a/assets/unbaked/scene.blend +++ b/assets/unbaked/scene.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66f728c728db0905aadf7f0052cb42cbaf72308100e3088e271af70d22ab3ec4 -size 80123820 +oid sha256:5ba3be1ad135735ed6ac111c2229004e8eb7d2d9442a873a5f49bd4cbc905f40 +size 10146216 diff --git a/assets/unbaked/scene/labels.png b/assets/unbaked/scene/labels.png new file mode 100644 index 0000000..7ae9d7b --- /dev/null +++ b/assets/unbaked/scene/labels.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22b0bcb35c11d4da7718d85136baadbc5801d9823661e1feecd8851d384ef290 +size 26579 diff --git a/assets/unbaked/scene/labels.xcf b/assets/unbaked/scene/labels.xcf new file mode 100644 index 0000000..823bd5d --- /dev/null +++ b/assets/unbaked/scene/labels.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28973e2b620fe500c7b820ea036ad81f65ff0181a597a480b9bcdf8ee4a5fe46 +size 81896 diff --git a/src/coolant/condenser.cpp b/src/coolant/condenser.cpp index 3692c73..f3b6472 100644 --- a/src/coolant/condenser.cpp +++ b/src/coolant/condenser.cpp @@ -26,14 +26,6 @@ double condenser::get_bubble_hl() void condenser::update(double secs) { - std::cout << "Condenser:\n\n"; - std::cout << "Level: " << level << "\n"; - std::cout << "Volume: " << volume << "\n"; - std::cout << "Height: " << height << "\n"; - std::cout << "Diameter: " << diameter << "\n"; - std::cout << "Pressure: " << get_pressure() << "\n"; - std::cout << "Teperature: " << heat << "\n\n"; - ((sim::coolant::fluid_holder*)this)->update(secs); } diff --git a/src/coolant/pump.cpp b/src/coolant/pump.cpp index 4bf4af3..5851266 100644 --- a/src/coolant/pump.cpp +++ b/src/coolant/pump.cpp @@ -6,8 +6,8 @@ using namespace sim::coolant; -pump::pump(fluid_holder& src, fluid_holder& dst, double mass, double radius, double l_per_rev, double friction) : - src(&src), dst(&dst), mass(mass), radius(radius), l_per_rev(l_per_rev), friction(friction) +pump::pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double l_per_rev, double friction) : + src(src), dst(dst), mass(mass), radius(radius), l_per_rev(l_per_rev), friction(friction) { power = 1e3; } diff --git a/src/coolant/pump.hpp b/src/coolant/pump.hpp index e7ed378..261d7b9 100644 --- a/src/coolant/pump.hpp +++ b/src/coolant/pump.hpp @@ -22,7 +22,7 @@ public: double power = 0; // watts - pump(fluid_holder& src, fluid_holder& dst, double mass, double radius, double l_per_rev, double friction); + pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double l_per_rev, double friction); double get_flow() const; // L/s double get_rpm() const; // rev/min diff --git a/src/coolant/valve.cpp b/src/coolant/valve.cpp index 8d19958..79ed2e2 100644 --- a/src/coolant/valve.cpp +++ b/src/coolant/valve.cpp @@ -3,25 +3,25 @@ using namespace sim::coolant; -valve::valve(fluid_holder& src, fluid_holder& dst, double max) : src(&src), dst(&dst), max(max) +valve::valve(fluid_holder* src, fluid_holder* dst, double max) : src(src), dst(dst), max(max) { } -void valve::set_state(double v) +void valve::add_open_speed(double v) { - if(v > 1) v = 1; - if(v < 0) v = 0; - state = v; + open_speed += v; } -void valve::open(double v) +void valve::clear_open_speed() { - set_state(state + v); + open_speed = 0; } void valve::update(double dt) { -// rate = a->extract_steam(dt, state * max, pressure) / dt; TODO + state += open_speed * dt; + if(state > 1) state = 1; + if(state < 0) state = 0; } diff --git a/src/coolant/valve.hpp b/src/coolant/valve.hpp index 1339b49..45060f2 100644 --- a/src/coolant/valve.hpp +++ b/src/coolant/valve.hpp @@ -13,15 +13,16 @@ class valve fluid_holder* const src; fluid_holder* const dst; + double open_speed = 0; double state = 0; public: - valve(fluid_holder& src, fluid_holder& dst, double max); + valve(fluid_holder* src, fluid_holder* dst, double max); - void open(double v); void update(double secs); - void set_state(double v); + void add_open_speed(double v); + void clear_open_speed(); constexpr double get_state() const { return state; } }; diff --git a/src/display.cpp b/src/display.cpp deleted file mode 100644 index 2ea7ce5..0000000 --- a/src/display.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include "display.hpp" - -#include -#include -#include - -void display::draw_text(int x, int y, const char* at) -{ - for(int i = 0;; i++) - { - const char* start = at; - char c = (at++)[0]; - - while(c != '\n' && c != '\0') - { - c = (at++)[0]; - } - - mvaddnstr(x + i, y, start, (size_t)(at - start)); - - if(c == '\0') - { - return; - } - } -} - -void display::draw_box(int x, int y, int h, int w) -{ - mvaddch(x, y, '+'); - - for(int i = 0; i < w - 2; i++) - { - addch('-'); - } - - addch('+'); - - for(int i = 0; i < h - 2; i++) - { - mvaddch(x + i + 1, y, '|'); - mvaddch(x + i + 1, y + w - 1, '|'); - } - - mvaddch(x + h - 1, y, '+'); - - for(int i = 0; i < w - 2; i++) - { - addch('-'); - } - - addch('+'); -} diff --git a/src/display.hpp b/src/display.hpp deleted file mode 100644 index be126e3..0000000 --- a/src/display.hpp +++ /dev/null @@ -1,11 +0,0 @@ - -#pragma once - -namespace display -{ - -void draw_text(int x, int y, const char* str); -void draw_box(int x, int y, int h, int w); - -} - diff --git a/src/electric/turbine.cpp b/src/electric/turbine.cpp index e69de29..286127a 100644 --- a/src/electric/turbine.cpp +++ b/src/electric/turbine.cpp @@ -0,0 +1,32 @@ + +#include "turbine.hpp" + +#include +#include + +using namespace sim::electric; + +constexpr static double calc_cylinder(double h, double d) +{ + double r = d / 2; + + return M_PI * r * r * h; +} + +turbine::turbine(coolant::fluid_t type, double height, double diameter, double level) : + height(height), diameter(diameter), sim::coolant::fluid_holder(type, calc_cylinder(height, diameter)) +{ + this->level = level; +} + +double turbine::get_bubble_hl() +{ + return (level / volume) * diameter * 0.5 / fluid.bubble_speed; +} + +void turbine::update(double secs) +{ + ((sim::coolant::fluid_holder*)this)->update(secs); +} + + diff --git a/src/electric/turbine.hpp b/src/electric/turbine.hpp index cf806ae..aa9afc5 100644 --- a/src/electric/turbine.hpp +++ b/src/electric/turbine.hpp @@ -1,10 +1,24 @@ #pragma once +#include "../coolant/fluid_holder.hpp" + namespace sim::electric { +class turbine : public sim::coolant::fluid_holder +{ + const double height; + const double diameter; + + virtual double get_bubble_hl(); +public: + + turbine(coolant::fluid_t type, double height, double diameter, double level); + + void update(double dt); +}; }; diff --git a/src/graphics/monitor/core.cpp b/src/graphics/monitor/core.cpp index 3a04381..0604e25 100644 --- a/src/graphics/monitor/core.cpp +++ b/src/graphics/monitor/core.cpp @@ -3,9 +3,11 @@ #include #include "core.hpp" +#include "helpers.hpp" #include "../locations.hpp" #include "../input/focus.hpp" #include "../mesh/arrays.hpp" +#include "../../system.hpp" #include @@ -15,6 +17,60 @@ using namespace sim::graphics; using namespace sim::graphics::monitor; +static void set_all(bool state) +{ + for(int i = 0; i < sim::system::active.reactor->rods.size(); i++) + { + sim::reactor::rod* r = sim::system::active.reactor->rods[i].get(); + + if(r->should_select()) + { + r->selected = state; + } + } +} + +struct core_monitor : public focus::focus_t +{ + virtual void on_keypress(int key, int sc, int action, int mods) + { + if(action != GLFW_PRESS) + { + return; + } + + sim::system& sys = sim::system::active; + + switch(key) + { + case GLFW_KEY_KP_7: + set_all(true); + break; + case GLFW_KEY_KP_8: + sys.reactor->move_cursor(-sys.reactor->height); + break; + case GLFW_KEY_KP_9: + set_all(false); + break; + case GLFW_KEY_KP_4: + sys.reactor->move_cursor(-1); + break; + case GLFW_KEY_KP_5: + sys.reactor->toggle_selected(); + break; + case GLFW_KEY_KP_6: + sys.reactor->move_cursor(1); + break; + case GLFW_KEY_KP_1: + sys.reactor->reset_rod_speed(); + break; + case GLFW_KEY_KP_2: + sys.reactor->move_cursor(sys.reactor->height); + break; + } + } +}; + struct core_joystick : public focus::focus_t { virtual void on_cursor_pos(double x, double y) @@ -40,19 +96,6 @@ core::core() { } -static void set_all(bool state) -{ - for(int i = 0; i < sim::system::active.reactor->rods.size(); i++) - { - sim::reactor::rod* r = sim::system::active.reactor->rods[i].get(); - - if(r->should_select()) - { - r->selected = state; - } - } -} - void core::init() { mesh1.model_matrix = locations::monitors[2]; @@ -80,6 +123,7 @@ void core::init() m_buttons[7].load_model("../assets/model/", "reactor_core_button8.stl"); m_buttons[8].load_model("../assets/model/", "reactor_core_button9.stl"); m_joystick.load_model("../assets/model/", "reactor_core_joystick.stl"); + m_monitor.load_model("../assets/model/", "reactor_core_input.stl"); m_scram.load_model("../assets/model/", "reactor_core_scram.stl"); } @@ -87,28 +131,28 @@ void core::update() { sim::system& sys = sim::system::active; + if(m_monitor.check_focus()) + focus::set(std::make_unique()); if(m_joystick.check_focus()) focus::set(std::make_unique()); if(m_scram.check_focus()) - sim::system::active.reactor->scram(); + sys.reactor->scram(); if(m_buttons[0].check_focus()) set_all(true); if(m_buttons[1].check_focus()) - sys.reactor->move_cursor(-sim::system::active.reactor->height); + sys.reactor->move_cursor(-sys.reactor->height); if(m_buttons[2].check_focus()) set_all(false); if(m_buttons[3].check_focus()) sys.reactor->move_cursor(-1); if(m_buttons[4].check_focus()) - sys.reactor->move_cursor(sim::system::active.reactor->height); + sys.reactor->toggle_selected(); if(m_buttons[5].check_focus()) sys.reactor->move_cursor(1); if(m_buttons[6].check_focus()) - sim::system::active.reactor->toggle_selected(); + sys.reactor->reset_rod_speed(); if(m_buttons[7].check_focus()) - sim::system::active.reactor->reset_rod_speed(); -// if(m_buttons[8].check_focus()) -// + sys.reactor->move_cursor(sys.reactor->height); } void core::render() diff --git a/src/graphics/monitor/core.hpp b/src/graphics/monitor/core.hpp index 71653dd..e6981f1 100644 --- a/src/graphics/monitor/core.hpp +++ b/src/graphics/monitor/core.hpp @@ -2,7 +2,6 @@ #pragma once #include "../mesh/glmesh.hpp" -#include "../../system.hpp" namespace sim::graphics::monitor { @@ -11,6 +10,7 @@ class core { sim::graphics::glmesh mesh1, mesh2; + sim::graphics::mesh m_monitor; sim::graphics::mesh m_buttons[9]; sim::graphics::mesh m_joystick; sim::graphics::mesh m_scram; diff --git a/src/graphics/monitor/helpers.hpp b/src/graphics/monitor/helpers.hpp new file mode 100644 index 0000000..4aae605 --- /dev/null +++ b/src/graphics/monitor/helpers.hpp @@ -0,0 +1,14 @@ + +#pragma once + +#include + +constexpr double show(double v, double m) +{ + return std::round(v * m) / m; +} + +constexpr double show(double v) +{ + return std::round(v * 1e3) * 1e-3; +} diff --git a/src/graphics/monitor/primary_loop.cpp b/src/graphics/monitor/primary_loop.cpp new file mode 100644 index 0000000..bd61b5f --- /dev/null +++ b/src/graphics/monitor/primary_loop.cpp @@ -0,0 +1,113 @@ + +#include +#include + +#include "helpers.hpp" +#include "primary_loop.hpp" +#include "../locations.hpp" +#include "../../system.hpp" +#include "../../coolant/valve.hpp" +#include "../input/focus.hpp" + +#include + +using namespace sim::graphics; +using namespace sim::graphics::monitor; + +struct valve_joystick : public focus::focus_t +{ + sim::coolant::valve* active; + + valve_joystick(sim::coolant::valve* v) : active(v) + { + + } + + virtual ~valve_joystick() + { + active->clear_open_speed(); + } + + virtual void on_cursor_pos(double x, double y) + { + active->add_open_speed(y * 1e-5); + } + + virtual void on_mouse_button(int button, int action, int mods) + { + if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) + { + focus::clear_focus(); + } + } + + virtual bool cursor_is_visible() + { + return false; + } +}; + + +primary_loop::primary_loop() +{ + +} + +void primary_loop::init() +{ + mesh1.model_matrix = locations::monitors[3]; + mesh2.model_matrix = glm::translate(mesh1.model_matrix, glm::vec3(0.5, 0, 0)); + + mesh1.colour_matrix = mesh2.colour_matrix = { + 1, 1, 1, 1, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0 + }; + + std::stringstream ss; + sim::graphics::mesh rmesh; + + ss << "Turbine Valves\n\n"; + ss << "Inlet\n"; + ss << "Bypass\n"; + + rmesh.load_text(ss.str().c_str(), 0.04); + mesh1.bind(); + mesh1.set(rmesh, GL_STATIC_DRAW); + + m_joystick_turbine_bypass.load_model("../assets/model", "turbine_valve_bypass_joystick.stl"); + m_joystick_turbine_inlet.load_model("../assets/model", "turbine_valve_inlet_joystick.stl"); +} + +void primary_loop::update() +{ + std::stringstream ss; + sim::graphics::mesh rmesh; + system& sys = sim::system::active; + + ss << "\n\n"; + ss << show( sys.turbine_inlet_valve->get_state() * 100 ) << " %\n"; + ss << show( sys.turbine_bypass_valve->get_state() * 100 ) << " %\n"; + + rmesh.load_text(ss.str().c_str(), 0.04); + mesh2.bind(); + mesh2.set(rmesh, GL_DYNAMIC_DRAW); + + if(m_joystick_turbine_bypass.check_focus()) + focus::set(std::make_unique(sys.turbine_bypass_valve.get())); + if(m_joystick_turbine_inlet.check_focus()) + focus::set(std::make_unique(sys.turbine_inlet_valve.get())); +} + +void primary_loop::render() +{ + mesh1.bind(); + mesh1.uniform(); + mesh1.render(); + + mesh2.bind(); + mesh2.uniform(); + mesh2.render(); +} + diff --git a/src/graphics/monitor/primary_loop.hpp b/src/graphics/monitor/primary_loop.hpp new file mode 100644 index 0000000..5982126 --- /dev/null +++ b/src/graphics/monitor/primary_loop.hpp @@ -0,0 +1,25 @@ + +#pragma once + +#include "../mesh/glmesh.hpp" + +namespace sim::graphics::monitor +{ + +class primary_loop +{ + sim::graphics::glmesh mesh1, mesh2; + + sim::graphics::mesh m_joystick_turbine_bypass; + sim::graphics::mesh m_joystick_turbine_inlet; + +public: + + primary_loop(); + void init(); + void update(); + void render(); +}; + +}; + diff --git a/src/graphics/monitor/vessel.cpp b/src/graphics/monitor/vessel.cpp index 6f133c7..45daa36 100644 --- a/src/graphics/monitor/vessel.cpp +++ b/src/graphics/monitor/vessel.cpp @@ -3,9 +3,11 @@ #include #include "vessel.hpp" +#include "helpers.hpp" #include "../../reactor/rod.hpp" #include "../../reactor/control/boron_rod.hpp" #include "../locations.hpp" +#include "../../system.hpp" #include #include @@ -49,16 +51,6 @@ void vessel::init() mesh1.set(rmesh, GL_STATIC_DRAW); } -static double show(double v, double m) -{ - return std::round(v * m) / m; -} - -static double show(double v) -{ - return std::round(v * 1e3) * 1e-3; -} - void vessel::update() { sim::system& sys = sim::system::active; diff --git a/src/graphics/monitor/vessel.hpp b/src/graphics/monitor/vessel.hpp index fb5e3a4..3906568 100644 --- a/src/graphics/monitor/vessel.hpp +++ b/src/graphics/monitor/vessel.hpp @@ -2,7 +2,6 @@ #pragma once #include "../mesh/glmesh.hpp" -#include "../../system.hpp" namespace sim::graphics::monitor { diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index abbfc1d..dedef36 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -20,6 +20,7 @@ #include "locations.hpp" #include "monitor/vessel.hpp" #include "monitor/core.hpp" +#include "monitor/primary_loop.hpp" #include "mesh/texture.hpp" #include "ui.hpp" @@ -31,6 +32,7 @@ static bool win_should_close = false; static glmesh MeshScene; static monitor::vessel MonitorVessel; static monitor::core MonitorCore; +static monitor::primary_loop MonitorPrimaryLoop; glm::mat4 window::projection_matrix; @@ -113,6 +115,7 @@ void window::create() MonitorCore.init(); MonitorVessel.init(); + MonitorPrimaryLoop.init(); glfwShowWindow(win); glViewport(0, 0, 800, 600); @@ -124,6 +127,7 @@ void window::update(double dt) MonitorCore.update(); MonitorVessel.update(); + MonitorPrimaryLoop.update(); ui::update(dt); } @@ -145,6 +149,7 @@ void window::render() MonitorCore.render(); MonitorVessel.render(); + MonitorPrimaryLoop.render(); ui::render(); diff --git a/src/reactor/builder.cpp b/src/reactor/builder.cpp index f78509f..3f30e58 100644 --- a/src/reactor/builder.cpp +++ b/src/reactor/builder.cpp @@ -7,7 +7,7 @@ using namespace sim::reactor; -sim::reactor::reactor sim::reactor::builder(const int W, const int H, const double CW, const double CH, fuel::fuel_rod fr, coolant::vessel& v, const char** lines) +sim::reactor::reactor sim::reactor::builder(const int W, const int H, const double CW, const double CH, fuel::fuel_rod fr, coolant::vessel* v, const char** lines) { std::vector> arr(W * H); diff --git a/src/reactor/builder.hpp b/src/reactor/builder.hpp index ecb1a5f..1064be0 100644 --- a/src/reactor/builder.hpp +++ b/src/reactor/builder.hpp @@ -13,7 +13,7 @@ namespace sim::reactor { -reactor builder(const int W, const int H, const double CW, const double CH, fuel::fuel_rod fr, coolant::vessel& v, const char** lines); +reactor builder(const int W, const int H, const double CW, const double CH, fuel::fuel_rod fr, coolant::vessel* v, const char** lines); }; diff --git a/src/reactor/control/boron_rod.cpp b/src/reactor/control/boron_rod.cpp index f7196ad..1830fc8 100644 --- a/src/reactor/control/boron_rod.cpp +++ b/src/reactor/control/boron_rod.cpp @@ -9,7 +9,7 @@ constexpr double boron_density = 2340000; // g/m^3 constexpr double boron_molar_mass = 10; // g/mol constexpr double boron_molar_density = boron_density / boron_molar_mass; // mol/m^3 -boron_rod::boron_rod(coolant::vessel& v) : coolant::pipe(v) +boron_rod::boron_rod(coolant::vessel* v) : coolant::pipe(v) { } diff --git a/src/reactor/control/boron_rod.hpp b/src/reactor/control/boron_rod.hpp index 63ef41a..7652cf0 100644 --- a/src/reactor/control/boron_rod.hpp +++ b/src/reactor/control/boron_rod.hpp @@ -18,7 +18,7 @@ class boron_rod : public coolant::pipe public: - boron_rod(coolant::vessel& v); + boron_rod(coolant::vessel* v); virtual void update(double secs); void set_reactivity(double a); diff --git a/src/reactor/coolant/pipe.cpp b/src/reactor/coolant/pipe.cpp index 984d229..bc06964 100644 --- a/src/reactor/coolant/pipe.cpp +++ b/src/reactor/coolant/pipe.cpp @@ -4,9 +4,9 @@ using namespace sim::reactor::coolant; -pipe::pipe(coolant::vessel& v) +pipe::pipe(coolant::vessel* v) { - this->vessel = &v; + this->vessel = v; this->steam = 0; } diff --git a/src/reactor/coolant/pipe.hpp b/src/reactor/coolant/pipe.hpp index 71cd9c1..001e9c1 100644 --- a/src/reactor/coolant/pipe.hpp +++ b/src/reactor/coolant/pipe.hpp @@ -22,7 +22,7 @@ protected: public: - pipe(coolant::vessel& v); + pipe(coolant::vessel* v); virtual std::unique_ptr clone() const { return std::make_unique(*this); } virtual bool should_display() const { return true; } diff --git a/src/system.cpp b/src/system.cpp index 8ee6dac..e3c787d 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -36,11 +36,13 @@ system::system() }; vessel = std::make_unique(sim::coolant::WATER, 8, 10, 300); - reactor = std::make_unique(sim::reactor::builder(19, 19, 1.0 / 4.0, 4, reactor::fuel::fuel_rod(0.5), *vessel.get(), layout)); + reactor = std::make_unique(sim::reactor::builder(19, 19, 1.0 / 4.0, 4, reactor::fuel::fuel_rod(0.5), vessel.get(), layout)); condenser = std::make_unique(sim::coolant::WATER, 8, 6, 200); + turbine = std::make_unique(sim::coolant::WATER, 6, 3, 20); - turbine_bypass_valve = std::make_unique(*vessel.get(), *condenser.get(), 1); - core_pump = std::make_unique(*condenser.get(), *vessel.get(), 1e6, 1, 100, 100); + turbine_inlet_valve = std::make_unique(vessel.get(), turbine.get(), 1); + turbine_bypass_valve = std::make_unique(vessel.get(), condenser.get(), 1); + core_pump = std::make_unique(condenser.get(), vessel.get(), 1e6, 1, 100, 100); } system::system(system&& o) @@ -48,7 +50,9 @@ system::system(system&& o) vessel = std::move(o.vessel); reactor = std::move(o.reactor); condenser = std::move(o.condenser); + turbine = std::move(o.turbine); turbine_bypass_valve = std::move(o.turbine_bypass_valve); + turbine_inlet_valve = std::move(o.turbine_inlet_valve); core_pump = std::move(o.core_pump); } @@ -57,8 +61,10 @@ void system::update(double dt) dt *= speed; vessel->update(dt); reactor->update(dt); -// condenser->update(dt); -// turbine_bypass_valve->update(dt); + condenser->update(dt); + turbine->update(dt); + turbine_inlet_valve->update(dt); + turbine_bypass_valve->update(dt); // core_pump->update(dt); } diff --git a/src/system.hpp b/src/system.hpp index db4405d..f3cfae0 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -8,6 +8,7 @@ #include "coolant/pump.hpp" #include "coolant/valve.hpp" #include "coolant/condenser.hpp" +#include "electric/turbine.hpp" #include "graphics/mesh/mesh.hpp" namespace sim @@ -20,8 +21,10 @@ struct system std::unique_ptr reactor; std::unique_ptr vessel; std::unique_ptr condenser; + std::unique_ptr turbine; std::unique_ptr core_pump; std::unique_ptr turbine_bypass_valve; + std::unique_ptr turbine_inlet_valve; sim::graphics::mesh scene; double speed = 1;