From 49c993154f20f9b7706d794004a0e48cd3ad9a7e Mon Sep 17 00:00:00 2001 From: Jay Robson Date: Sat, 3 Feb 2024 18:12:18 +1100 Subject: [PATCH] added some primary coolant loop gui stuff --- CMakeLists.txt | 2 +- assets/model/reactor_core_joystick.stl | 2 +- .../model/turbine_valve_bypass_joystick.stl | 3 + assets/model/turbine_valve_inlet_joystick.stl | 3 + assets/scene-baked.glb | 4 +- assets/unbaked/scene.blend | 4 +- assets/unbaked/scene/labels.png | 3 + assets/unbaked/scene/labels.xcf | Bin 0 -> 81896 bytes src/coolant/condenser.cpp | 8 -- src/coolant/pump.cpp | 4 +- src/coolant/pump.hpp | 2 +- src/coolant/valve.cpp | 16 +-- src/coolant/valve.hpp | 7 +- src/display.cpp | 54 --------- src/display.hpp | 11 -- src/electric/turbine.cpp | 32 +++++ src/electric/turbine.hpp | 14 +++ src/graphics/monitor/core.cpp | 84 +++++++++---- src/graphics/monitor/core.hpp | 2 +- src/graphics/monitor/helpers.hpp | 14 +++ src/graphics/monitor/primary_loop.cpp | 113 ++++++++++++++++++ src/graphics/monitor/primary_loop.hpp | 25 ++++ src/graphics/monitor/vessel.cpp | 12 +- src/graphics/monitor/vessel.hpp | 1 - src/graphics/window.cpp | 5 + src/reactor/builder.cpp | 2 +- src/reactor/builder.hpp | 2 +- src/reactor/control/boron_rod.cpp | 2 +- src/reactor/control/boron_rod.hpp | 2 +- src/reactor/coolant/pipe.cpp | 4 +- src/reactor/coolant/pipe.hpp | 2 +- src/system.cpp | 16 ++- src/system.hpp | 3 + 33 files changed, 321 insertions(+), 137 deletions(-) create mode 100644 assets/model/turbine_valve_bypass_joystick.stl create mode 100644 assets/model/turbine_valve_inlet_joystick.stl create mode 100644 assets/unbaked/scene/labels.png create mode 100644 assets/unbaked/scene/labels.xcf delete mode 100644 src/display.cpp delete mode 100644 src/display.hpp create mode 100644 src/graphics/monitor/helpers.hpp create mode 100644 src/graphics/monitor/primary_loop.cpp create mode 100644 src/graphics/monitor/primary_loop.hpp 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 817f7a6..475670b 100644 --- a/assets/model/reactor_core_joystick.stl +++ b/assets/model/reactor_core_joystick.stl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5cf737ad5e6ac820cae1eaccdff3770800a5a163d130fb2a19d75653e066b937 +oid sha256:80061016f494879ad7e05e7d3f95743935589c7d8d68438c56c1930ac3f6b67d size 2384 diff --git a/assets/model/turbine_valve_bypass_joystick.stl b/assets/model/turbine_valve_bypass_joystick.stl new file mode 100644 index 0000000..b4ba457 --- /dev/null +++ b/assets/model/turbine_valve_bypass_joystick.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32a36024215b2eabc09a6c23aa133a3b5653d9666a634d56f7304c97e8379d76 +size 2384 diff --git a/assets/model/turbine_valve_inlet_joystick.stl b/assets/model/turbine_valve_inlet_joystick.stl new file mode 100644 index 0000000..34e7452 --- /dev/null +++ b/assets/model/turbine_valve_inlet_joystick.stl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42d79043838dc5425fedc62b1f80b53d75c4039bd8ce20788c517b824f0ca6ab +size 2384 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 0000000000000000000000000000000000000000..c6d49ea5332690df3998d99c43ebcf1837d162c2 GIT binary patch literal 81896 zcmeI53!GI|+5h)Bb7h9haAyGZa0lfs2;(iUZ&8$%rjnOLK$%1!F3R+p;58^qGgC4D zrk15yYQ9#Irs!)bX`=I0kwM5?7-*DZ?ETBYwfky zW$))%&sxtqrT(iC?=@$a>h6S*M*gZRR|}ftZ~Ro-=LoylGQYXVlM|p8E8J&mS&Mjf+}; z+T>HF4LfB{{Z!Eu`}^4wH|YuOo- zXPz>j?w0C1MY)_bdG54fQ|sqUn=-F{*38t5d2=8Z_O)D3`r7=t^XgA-NKK(D;M9s@7G;EZv1~?_nqA#3{!{?1=!rP{%0>&hE3_mesEMdaztucX_#L9*$#UJ zVGZBG<>Nmjb`Q3UIQyPgx4rl3U#^|fwX3D(TYWJS$Dm}88F6=;FunDX&YkmEO~(Ym z?54J1=7r&%@)+qQ!C4)`%v-%X=8-eM|9okmO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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;