fixed valves :D
This commit is contained in:
parent
16f407bc03
commit
f8212990b1
BIN
assets/unbaked/scene.blend (Stored with Git LFS)
BIN
assets/unbaked/scene.blend (Stored with Git LFS)
Binary file not shown.
|
@ -10,7 +10,7 @@ constexpr static double calc_cylinder(double h, double d)
|
|||
{
|
||||
double r = d / 2;
|
||||
|
||||
return M_PI * r * r * h;
|
||||
return M_PI * r * r * h * 1000;
|
||||
}
|
||||
|
||||
condenser::condenser(fluid_t type, double height, double diameter, double mass, double level) :
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
|
||||
#include "condenser_secondary.hpp"
|
||||
#include "../conversions/temperature.hpp"
|
||||
#include "../util/constants.hpp"
|
||||
#include "../system.hpp"
|
||||
|
||||
using namespace sim::coolant;
|
||||
|
||||
condenser_secondary::condenser_secondary(condenser* primary, double volume, double level) :
|
||||
primary(primary), fluid_holder(primary->fluid, volume, 0)
|
||||
condenser_secondary::condenser_secondary(condenser* primary, evaporator* source) :
|
||||
primary(primary), source(source), fluid_holder(primary->fluid, 0, 0)
|
||||
{
|
||||
this->level = level;
|
||||
|
||||
}
|
||||
|
||||
void condenser_secondary::update(double dt)
|
||||
double condenser_secondary::add_fluid(double amount, double heat)
|
||||
{
|
||||
((fluid_holder*)this)->update(dt);
|
||||
heat = primary->add_heat(get_thermal_mass(), heat);
|
||||
heat = primary->add_heat(fluid.l_to_g(amount), heat);
|
||||
return source->add_fluid(amount, heat);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fluid_holder.hpp"
|
||||
#include "evaporator.hpp"
|
||||
#include "condenser.hpp"
|
||||
|
||||
namespace sim::coolant
|
||||
|
@ -10,12 +11,27 @@ namespace sim::coolant
|
|||
class condenser_secondary : public fluid_holder
|
||||
{
|
||||
condenser* const primary;
|
||||
evaporator* const source;
|
||||
|
||||
public:
|
||||
|
||||
condenser_secondary(condenser* primary, double volume, double level);
|
||||
condenser_secondary(condenser* primary, evaporator* source);
|
||||
|
||||
void update(double dt);
|
||||
virtual double add_heat(double m, double t) { return source->add_heat(m, t); }
|
||||
virtual void add_steam(double amount, double t) { return source->add_steam(amount, t); }
|
||||
virtual double extract_fluid(double amount) { return source->extract_fluid(amount); }
|
||||
|
||||
virtual double add_fluid(double amount, double heat);
|
||||
|
||||
virtual double get_volume() const { return source->get_volume(); }
|
||||
virtual double get_level() const { return source->get_level(); }
|
||||
virtual double get_heat() const { return source->get_heat(); } // celsius
|
||||
virtual double get_steam() const { return source->get_steam(); } // grams
|
||||
virtual double get_steam_volume() const { return source->get_steam_volume(); } // litres
|
||||
virtual double get_mass() const { return source->get_mass(); } // grams
|
||||
virtual double get_thermal_mass() const { return source->get_thermal_mass(); } // grams
|
||||
virtual double get_pressure() const { return source->get_pressure(); } // pascals
|
||||
virtual double get_steam_density() const { return source->get_steam_density(); } // g/L
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "evaporator.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
using namespace sim::coolant;
|
||||
|
||||
|
@ -9,12 +10,30 @@ constexpr static double calc_cylinder(double h, double d)
|
|||
{
|
||||
double r = d / 2;
|
||||
|
||||
return M_PI * r * r * h;
|
||||
return M_PI * r * r * h * 1000;
|
||||
}
|
||||
|
||||
evaporator::evaporator(fluid_t type, double height, double diameter, double mass, double level) :
|
||||
height(height), diameter(diameter), fluid_holder(type, calc_cylinder(height, diameter), mass)
|
||||
height(height),
|
||||
diameter(diameter),
|
||||
fluid_holder(type, calc_cylinder(height, diameter), mass)
|
||||
{
|
||||
this->level = level;
|
||||
}
|
||||
|
||||
double evaporator::get_steam_output()
|
||||
{
|
||||
return steam_output;
|
||||
}
|
||||
|
||||
void evaporator::update(double dt)
|
||||
{
|
||||
((fluid_holder*)this)->update(dt);
|
||||
/*
|
||||
double m = std::pow(0.5, dt / 3600);
|
||||
double steam_out = steam * (1 - m);
|
||||
steam *= m;
|
||||
|
||||
steam_output = steam_out / dt;*/
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,14 @@ class evaporator : public fluid_holder
|
|||
const double height;
|
||||
const double diameter;
|
||||
|
||||
double steam_output = 0;
|
||||
|
||||
public:
|
||||
|
||||
evaporator(fluid_t type, double height, double diameter, double mass, double level);
|
||||
|
||||
double get_steam_output();
|
||||
void update(double dt);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -31,13 +31,13 @@ double fluid_holder::add_heat(double m1, double t1)
|
|||
|
||||
double fluid_holder::add_fluid(double v2, double t2)
|
||||
{
|
||||
if(level + v2 > volume)
|
||||
if(level + v2 > volume - 1e-3)
|
||||
{
|
||||
v2 = volume - level;
|
||||
v2 = volume - level - 1e-3;
|
||||
}
|
||||
|
||||
int m1 = get_thermal_mass();
|
||||
int m2 = fluid.l_to_g(v2);
|
||||
double m1 = get_thermal_mass();
|
||||
double m2 = fluid.l_to_g(v2);
|
||||
|
||||
double t1 = get_heat();
|
||||
double t = t1 - t2;
|
||||
|
@ -50,9 +50,9 @@ double fluid_holder::add_fluid(double v2, double t2)
|
|||
|
||||
double fluid_holder::extract_fluid(double amount)
|
||||
{
|
||||
if(amount < level)
|
||||
if(amount < level - 1e-3)
|
||||
{
|
||||
level -= amount;
|
||||
level -= amount - 1e-3;
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -78,18 +78,25 @@ void fluid_holder::add_steam(double m2, double t2)
|
|||
steam += m2;
|
||||
}
|
||||
|
||||
double fluid_holder::get_pressure() const
|
||||
double fluid_holder::calc_pressure(double heat, double volume, double mol)
|
||||
{
|
||||
double T = conversions::temperature::c_to_k(heat);
|
||||
double V = get_steam_volume() * 0.001;
|
||||
double n = fluid.g_to_mol(steam);
|
||||
double V = volume * 0.001;
|
||||
|
||||
if(V == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return V == 0 ? 0 : (mol * T * constants::R) / V;
|
||||
}
|
||||
|
||||
return (n * T * constants::R) / V;
|
||||
double fluid_holder::calc_pressure_mol(double heat, double volume, double pressure)
|
||||
{
|
||||
double T = conversions::temperature::c_to_k(heat);
|
||||
double V = volume * 0.001;
|
||||
|
||||
return (V * pressure) / (T * constants::R);
|
||||
}
|
||||
|
||||
double fluid_holder::get_pressure() const
|
||||
{
|
||||
return calc_pressure(heat, get_steam_volume(), fluid.g_to_mol(get_steam()));
|
||||
}
|
||||
|
||||
double fluid_holder::get_steam_density() const
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
virtual double get_pressure() const; // pascals
|
||||
virtual double get_steam_density() const; // g/L
|
||||
|
||||
static double calc_pressure(double temp, double volume, double mass);
|
||||
static double calc_pressure_mol(double temp, double volume, double pressure);
|
||||
|
||||
void update(double dt);
|
||||
};
|
||||
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
|
||||
using namespace sim::coolant;
|
||||
|
||||
pump::pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double power, double l_per_rev, double friction) :
|
||||
pump::pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double power, double l_per_rev, double friction, mode_t mode, double target) :
|
||||
src(src),
|
||||
dst(dst),
|
||||
mass(mass),
|
||||
radius(radius),
|
||||
l_per_rev(l_per_rev),
|
||||
friction(friction),
|
||||
max_power(power)
|
||||
max_power(power),
|
||||
mode(mode),
|
||||
target(target)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -66,20 +68,33 @@ void pump::update(double dt)
|
|||
{
|
||||
if(powered)
|
||||
{
|
||||
power = pid.calculate(dt, src->get_volume() / 2, src->get_steam_volume());
|
||||
switch(mode)
|
||||
{
|
||||
case mode_t::SRC:
|
||||
power = pid.calculate(dt, target, src->get_steam_volume());
|
||||
break;
|
||||
case mode_t::DST:
|
||||
power = pid.calculate(dt, target, dst->get_level());
|
||||
break;
|
||||
case mode_t::NONE:
|
||||
power = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
velocity += calc_work(dt * power * max_power, mass);
|
||||
}
|
||||
|
||||
fluid_holder fh_src(*src);
|
||||
fluid_holder fh_dst(*dst);
|
||||
else
|
||||
{
|
||||
power = 0;
|
||||
}
|
||||
|
||||
double src_heat = src->get_heat();
|
||||
double p_diff_1 = dst->get_pressure() - src->get_pressure();
|
||||
double src_volume = fh_src.extract_fluid(get_flow_target() * dt);
|
||||
double dst_volume = fh_dst.add_fluid(src_volume, src_heat);
|
||||
|
||||
src->extract_fluid(dst_volume);
|
||||
dst->add_fluid(dst_volume, src_heat);
|
||||
double max_volume = std::min(src->get_level(), dst->get_level());
|
||||
double src_volume = src->extract_fluid(std::min(get_flow_target() * dt, max_volume));
|
||||
double dst_volume = dst->add_fluid(src_volume, src_heat);
|
||||
|
||||
double p_diff_2 = dst->get_pressure() - src->get_pressure();
|
||||
double p_diff = (p_diff_1 + p_diff_2) / 2;
|
||||
|
|
|
@ -20,15 +20,25 @@ class pump
|
|||
|
||||
public:
|
||||
|
||||
enum mode_t
|
||||
{
|
||||
SRC,
|
||||
DST,
|
||||
NONE
|
||||
};
|
||||
|
||||
const mode_t mode;
|
||||
|
||||
const double mass; // grams
|
||||
const double radius; // meters
|
||||
const double l_per_rev; // litres
|
||||
const double friction; // J/rev
|
||||
const double max_power; // W
|
||||
const double target; // L
|
||||
|
||||
bool powered = false;
|
||||
|
||||
pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double power, double l_per_rev, double friction);
|
||||
pump(fluid_holder* src, fluid_holder* dst, double mass, double radius, double power, double l_per_rev, double friction, mode_t mode, double target);
|
||||
|
||||
double get_flow() const; // L/s
|
||||
double get_flow_target() const; // L/s
|
||||
|
|
|
@ -7,8 +7,8 @@ sink::sink(fluid_t type, double heat, double pressure, double steam_density) :
|
|||
heat(heat),
|
||||
pressure(pressure),
|
||||
steam_density(steam_density),
|
||||
fluid_holder(type, 1, 1)
|
||||
fluid_holder(type, 2e9, 0)
|
||||
{
|
||||
|
||||
level = 1e9;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,48 +39,18 @@ void valve::update(double dt)
|
|||
double pressure1 = src->get_pressure(); // Pa
|
||||
double pressure2 = dst->get_pressure();
|
||||
|
||||
int overshoots = 0;
|
||||
double m = max * state * dt;
|
||||
double temp, mass;
|
||||
double m = max * state;
|
||||
double diff = (pressure1 - pressure2);
|
||||
double remove = diff - diff * std::pow(1 - m, dt);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
double diff = (pressure1 - pressure2) * m; // L
|
||||
double mol = fluid_holder::calc_pressure_mol(src->get_heat(), src->get_steam_volume(), pressure1 - remove);
|
||||
double mass = src->get_steam() - src->fluid.mol_to_g(mol);
|
||||
|
||||
if(diff > 0)
|
||||
{
|
||||
temp = src->get_heat();
|
||||
mass = std::min(diff * src->get_steam_density(), src->get_steam());
|
||||
}
|
||||
double heat1 = src->get_heat(); // C
|
||||
double heat2 = dst->get_heat();
|
||||
|
||||
else
|
||||
{
|
||||
temp = dst->get_heat();
|
||||
mass = std::min(diff * dst->get_steam_density(), dst->get_steam());
|
||||
}
|
||||
|
||||
fluid_holder fh_src(*src);
|
||||
fluid_holder fh_dst(*dst);
|
||||
|
||||
fh_src.add_steam(-mass, temp);
|
||||
fh_dst.add_steam(mass, temp);
|
||||
|
||||
// if((pressure1 > fh_dst.get_pressure()) == (pressure2 < fh_src.get_pressure()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
overshoots += 1;
|
||||
m *= 0.5;
|
||||
}
|
||||
|
||||
if(overshoots > 0)
|
||||
{
|
||||
std::cout << "Warning: overshot " << overshoots << " times\n";
|
||||
}
|
||||
|
||||
src->add_steam(-mass, temp);
|
||||
dst->add_steam(mass, temp);
|
||||
src->add_steam(-mass, heat2);
|
||||
dst->add_steam(mass, heat1);
|
||||
|
||||
this->flow = mass / dt;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ constexpr static double calc_cylinder(double h, double d)
|
|||
{
|
||||
double r = d / 2;
|
||||
|
||||
return M_PI * r * r * h;
|
||||
return M_PI * r * r * h * 1000;
|
||||
}
|
||||
|
||||
turbine::turbine(coolant::fluid_t type, coolant::condenser* condenser, double length, double diameter, double mass) :
|
||||
|
|
|
@ -83,12 +83,12 @@ void primary_loop::init()
|
|||
ss << "Turbine Inlet Valve\n\n";
|
||||
ss << "Opened\nFlow\n\n";
|
||||
ss << "Primary Pump\n\n";
|
||||
ss << "State\nPower\nSpeed\nFlow\n\n";
|
||||
ss << "Power\nSpeed\nFlow\n\n";
|
||||
ss << "Condenser\n\n";
|
||||
ss << "Heat\n";
|
||||
ss << "Steam\n";
|
||||
ss << "Pressure\n";
|
||||
ss << "Level\n\n";
|
||||
ss << "Level\n";
|
||||
|
||||
rmesh.load_text(ss.str().c_str(), 0.04);
|
||||
mesh1.bind();
|
||||
|
@ -116,15 +116,14 @@ void primary_loop::update(double dt)
|
|||
ss << show( sys.turbine_inlet_valve->get_state() * 100 ) << " %\n";
|
||||
ss << show( sys.turbine_inlet_valve->get_flow() / 1000 ) << " kg/s\n";
|
||||
ss << "\n\n\n";
|
||||
ss << sys.primary_pump->get_state_string() << "\n";
|
||||
ss << show( sys.primary_pump->get_power() / 1000 ) << " kW\n";
|
||||
ss << show( sys.primary_pump->get_power() * 100 ) << " %\n";
|
||||
ss << show( sys.primary_pump->get_rpm() ) << " r/min\n";
|
||||
ss << show( sys.primary_pump->get_flow_mass() / 1000 ) << " kg/s\n";
|
||||
ss << "\n\n\n";
|
||||
ss << show( sys.condenser->get_heat() ) << " C\n";
|
||||
ss << show( sys.condenser->get_steam() ) << " g\n";
|
||||
ss << show( sys.condenser->get_pressure() / 1000 ) << " kPa\n";
|
||||
ss << show( sys.condenser->get_level() ) << " / " << show( sys.condenser->get_volume() ) << " L\n";
|
||||
ss << show( sys.condenser->get_level() / 1000 ) << " / " << show( sys.condenser->get_volume() / 1000 ) << " kL\n";
|
||||
|
||||
rmesh.load_text(ss.str().c_str(), 0.04);
|
||||
mesh2.bind();
|
||||
|
|
|
@ -23,18 +23,16 @@ secondary_loop::secondary_loop()
|
|||
void secondary_loop::toggle_secondary_pump()
|
||||
{
|
||||
system& sys = sim::system::active;
|
||||
static bool state = false;
|
||||
state = !state;
|
||||
// sys.secondary_pump->powered = state = !sys.secondary_pump->powered;
|
||||
bool state = false;
|
||||
sys.secondary_pump->powered = state = !sys.secondary_pump->powered;
|
||||
gm_switch_2.model_matrix = glm::translate(glm::mat4(1), glm::vec3(0, state ? 0.07 : 0, 0));
|
||||
}
|
||||
|
||||
void secondary_loop::toggle_freight_pump()
|
||||
{
|
||||
system& sys = sim::system::active;
|
||||
static bool state = false;
|
||||
state = !state;
|
||||
// sys.freight_pump->powered = state = !sys.freight_pump->powered;
|
||||
bool state = false;
|
||||
sys.freight_pump->powered = state = !sys.freight_pump->powered;
|
||||
gm_switch_3.model_matrix = glm::translate(glm::mat4(1), glm::vec3(0, state ? 0.07 : 0, 0));
|
||||
}
|
||||
|
||||
|
@ -53,7 +51,12 @@ void secondary_loop::init()
|
|||
std::stringstream ss;
|
||||
sim::graphics::mesh rmesh;
|
||||
|
||||
ss << "Secondary Loop\n";
|
||||
ss << "Cooling Tower\n\n";
|
||||
ss << "Heat\nSteam\nPressure\nLevel\n\n";
|
||||
ss << "Secondary Pump\n\n";
|
||||
ss << "Power\nSpeed\nFlow\n\n";
|
||||
ss << "Freight Pump\n\n";
|
||||
ss << "Power\nSpeed\nFlow\n\n";
|
||||
|
||||
rmesh.load_text(ss.str().c_str(), 0.04);
|
||||
mesh1.bind();
|
||||
|
@ -79,8 +82,19 @@ void secondary_loop::update(double dt)
|
|||
sim::graphics::mesh rmesh;
|
||||
system& sys = sim::system::active;
|
||||
|
||||
//TODO
|
||||
ss << "TODO\n";
|
||||
ss << "\n\n\n";
|
||||
ss << show( sys.evaporator->get_heat() ) << " C\n";
|
||||
ss << show( sys.evaporator->get_steam_output() ) << " g/s\n";
|
||||
ss << show( sys.evaporator->get_pressure() ) << " Pa\n";
|
||||
ss << show( sys.evaporator->get_level() / 1000 ) << " / " << show( sys.evaporator->get_volume() / 1000 ) << " kL\n";
|
||||
ss << "\n\n\n";
|
||||
ss << show( sys.secondary_pump->get_power() * 100 ) << " %\n";
|
||||
ss << show( sys.secondary_pump->get_rpm() ) << " r/min\n";
|
||||
ss << show( sys.secondary_pump->get_flow_mass() / 1000 ) << " kg/s\n";
|
||||
ss << "\n\n\n";
|
||||
ss << show( sys.freight_pump->get_power() * 100 ) << " %\n";
|
||||
ss << show( sys.freight_pump->get_rpm() ) << " r/min\n";
|
||||
ss << show( sys.freight_pump->get_flow_mass() / 1000 ) << " kg/s\n";
|
||||
|
||||
rmesh.load_text(ss.str().c_str(), 0.04);
|
||||
mesh2.bind();
|
||||
|
|
|
@ -89,7 +89,7 @@ void vessel::update(double dt)
|
|||
ss << show( sys.vessel->get_heat() ) << " C\n";
|
||||
ss << show( sys.vessel->get_steam() ) << " g\n";
|
||||
ss << show( sys.vessel->get_pressure() * 0.001 ) << " kPa\n";
|
||||
ss << show( sys.vessel->get_level() ) << " / " << show( sys.vessel->get_volume() ) << " L\n";
|
||||
ss << show( sys.vessel->get_level() / 1000 ) << " / " << show( sys.vessel->get_volume() / 1000 ) << " kL\n";
|
||||
ss << show( sys.vessel->get_void_ratio() * 100 ) << " %\n\n\n\n";
|
||||
ss << show( sys.reactor->get_energy_output() * 0.001 ) << " kW\n";
|
||||
ss << show( sys.reactor->get_flux() ) << " n/cm2/s\n\n\n";
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "graphics/camera.hpp"
|
||||
|
||||
#include "system.hpp"
|
||||
#include "tests.hpp"
|
||||
|
||||
using namespace sim;
|
||||
|
||||
|
@ -32,6 +33,9 @@ int main()
|
|||
{
|
||||
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
|
||||
|
||||
// tests::run();
|
||||
// return 0;
|
||||
|
||||
graphics::window::create();
|
||||
|
||||
long clock = get_now();
|
||||
|
|
|
@ -13,7 +13,7 @@ constexpr static double calc_cylinder(double h, double d)
|
|||
{
|
||||
double r = d / 2;
|
||||
|
||||
return M_PI * r * r * h;
|
||||
return M_PI * r * r * h * 1000;
|
||||
}
|
||||
|
||||
vessel::vessel(sim::coolant::fluid_t fluid, double height, double diameter, double mass, double level) :
|
||||
|
|
|
@ -35,14 +35,21 @@ system::system()
|
|||
" C C C C "
|
||||
};
|
||||
|
||||
vessel = std::make_unique<reactor::coolant::vessel>(sim::coolant::WATER, 8, 10, 6e6, 500);
|
||||
vessel = std::make_unique<reactor::coolant::vessel>(sim::coolant::WATER, 8, 10, 6e6, 5e5);
|
||||
reactor = std::make_unique<reactor::reactor>(sim::reactor::builder(19, 19, 1.0 / 4.0, 4, reactor::fuel::fuel_rod(0.5), vessel.get(), layout));
|
||||
condenser = std::make_unique<coolant::condenser>(sim::coolant::WATER, 8, 6, 3e6, 0);
|
||||
condenser = std::make_unique<coolant::condenser>(sim::coolant::WATER, 6, 4, 3e6, 0);
|
||||
turbine = std::make_unique<electric::turbine>(sim::coolant::WATER, condenser.get(), 6, 3, 2e6);
|
||||
|
||||
turbine_inlet_valve = std::make_unique<coolant::valve>(vessel.get(), turbine.get(), 0, 1e-2);
|
||||
turbine_bypass_valve = std::make_unique<coolant::valve>(vessel.get(), condenser.get(), 0, 1e-2);
|
||||
primary_pump = std::make_unique<coolant::pump>(condenser.get(), vessel.get(), 1e5, 1, 1e4, 0.1, 10);
|
||||
sink = std::make_unique<coolant::sink>(sim::coolant::WATER, 11, 0, 0);
|
||||
evaporator = std::make_unique<coolant::evaporator>(sim::coolant::WATER, 2, 30, 0, 1000);
|
||||
condenser_secondary = std::make_unique<coolant::condenser_secondary>(condenser.get(), evaporator.get());
|
||||
|
||||
turbine_inlet_valve = std::make_unique<coolant::valve>(vessel.get(), turbine.get(), 0, 0.5);
|
||||
turbine_bypass_valve = std::make_unique<coolant::valve>(vessel.get(), condenser.get(), 0, 0.5);
|
||||
|
||||
primary_pump = std::make_unique<coolant::pump>(condenser.get(), vessel.get(), 1e5, 1, 1e4, 0.1, 10, coolant::pump::mode_t::SRC, 35000);
|
||||
secondary_pump = std::make_unique<coolant::pump>(evaporator.get(), condenser_secondary.get(), 1e5, 1, 1e4, 0.1, 10, coolant::pump::mode_t::NONE, 0);
|
||||
freight_pump = std::make_unique<coolant::pump>(sink.get(), evaporator.get(), 1e5, 1, 1e4, 0.1, 10, coolant::pump::mode_t::DST, 1e6);
|
||||
}
|
||||
|
||||
system::system(system&& o)
|
||||
|
@ -51,9 +58,17 @@ system::system(system&& o)
|
|||
reactor = std::move(o.reactor);
|
||||
condenser = std::move(o.condenser);
|
||||
turbine = std::move(o.turbine);
|
||||
|
||||
sink = std::move(o.sink);
|
||||
condenser_secondary = std::move(o.condenser_secondary);
|
||||
evaporator = std::move(o.evaporator);
|
||||
|
||||
turbine_bypass_valve = std::move(o.turbine_bypass_valve);
|
||||
turbine_inlet_valve = std::move(o.turbine_inlet_valve);
|
||||
|
||||
primary_pump = std::move(o.primary_pump);
|
||||
secondary_pump = std::move(o.secondary_pump);
|
||||
freight_pump = std::move(o.freight_pump);
|
||||
}
|
||||
|
||||
void system::update(double dt)
|
||||
|
@ -68,6 +83,12 @@ void system::update(double dt)
|
|||
|
||||
turbine->update(dt);
|
||||
condenser->update(dt);
|
||||
primary_pump->update(dt);
|
||||
|
||||
// evaporator->update(dt);
|
||||
// condenser_secondary->update(dt);
|
||||
|
||||
// primary_pump->update(dt);
|
||||
// secondary_pump->update(dt);
|
||||
// freight_pump->update(dt);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include "coolant/pump.hpp"
|
||||
#include "coolant/valve.hpp"
|
||||
#include "coolant/condenser.hpp"
|
||||
#include "coolant/condenser_secondary.hpp"
|
||||
#include "coolant/evaporator.hpp"
|
||||
#include "coolant/sink.hpp"
|
||||
#include "electric/turbine.hpp"
|
||||
#include "graphics/mesh/mesh.hpp"
|
||||
|
||||
|
@ -20,11 +23,20 @@ struct system
|
|||
|
||||
std::unique_ptr<sim::reactor::reactor> reactor;
|
||||
std::unique_ptr<sim::reactor::coolant::vessel> vessel;
|
||||
|
||||
std::unique_ptr<sim::coolant::sink> sink;
|
||||
std::unique_ptr<sim::coolant::condenser> condenser;
|
||||
std::unique_ptr<sim::coolant::condenser_secondary> condenser_secondary;
|
||||
std::unique_ptr<sim::coolant::evaporator> evaporator;
|
||||
std::unique_ptr<sim::electric::turbine> turbine;
|
||||
|
||||
std::unique_ptr<sim::coolant::pump> primary_pump;
|
||||
std::unique_ptr<sim::coolant::pump> secondary_pump;
|
||||
std::unique_ptr<sim::coolant::pump> freight_pump;
|
||||
|
||||
std::unique_ptr<sim::coolant::valve> turbine_bypass_valve;
|
||||
std::unique_ptr<sim::coolant::valve> turbine_inlet_valve;
|
||||
|
||||
sim::graphics::mesh scene;
|
||||
double speed = 1;
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
#include "tests.hpp"
|
||||
#include "coolant/valve.hpp"
|
||||
#include "coolant/fluid_holder.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace sim;
|
||||
using namespace sim::coolant;
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, const fluid_holder& fh)
|
||||
{
|
||||
o << "Fluid Holder\n";
|
||||
o << "Heat " << fh.get_heat() << " C\n";
|
||||
o << "Steam " << fh.get_steam() << " g\n";
|
||||
o << "Pressure " << fh.get_pressure() << " Pa\n";
|
||||
o << "Volume " << fh.get_level() / 1000 << " / " << fh.get_volume() / 1000 << " kL\n\n";
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void tests::run()
|
||||
{
|
||||
fluid_holder src(WATER, 1e6, 0);
|
||||
fluid_holder dst(WATER, 1e6, 0);
|
||||
|
||||
src.add_fluid(1e5, 11);
|
||||
|
||||
valve v(&src, &dst, 1, 0.5);
|
||||
double dt = 0.001;
|
||||
double at = 0;
|
||||
|
||||
for(int i = 0; i < 10000; i++)
|
||||
{
|
||||
src.update(dt);
|
||||
dst.update(dt);
|
||||
v.update(dt);
|
||||
|
||||
std::cout << at << "\t" << src.get_pressure() << "\t" << dst.get_pressure() << "\n";
|
||||
at += dt;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace sim::tests
|
||||
{
|
||||
|
||||
void run();
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue