Compare commits

..

1 Commits

Author SHA1 Message Date
5d7a521945 Обновление
Уточнение ГУ
2025-05-14 22:22:51 +03:00
9 changed files with 53 additions and 92 deletions

View File

@@ -111,7 +111,6 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>./include</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'explicit10.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

10
es5.plt
View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'explicit5.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

View File

@@ -6,16 +6,18 @@
class System{ class System{
Object& _obj; Object& _obj;
Mesh _mesh; Mesh _mesh;
double _a; double _a1;
double _a2;
double _step; double _step;
public: public:
System(Object& obj, double step = 10., double a1 = 1.): _obj(obj), _mesh(obj, step), _a(a1), _step(step) {} System(Object& obj, double step = 10., double a1 = 1., double a2 = 1.): _obj(obj), _mesh(obj, step), _a1(a1), _a2(a2), _step(step) {}
void DefineBounds(int, int, int, int); void DefineBounds(int, int, int, int);
std::vector<std::vector<Node*>>& Nodes(); std::vector<std::vector<Node*>>& Nodes();
std::vector<Node*>& LineX(); std::vector<Node*>& LineX();
std::vector<Node*>& LineY(); std::vector<Node*>& LineY();
double step() const { return _step; } double step() const { return _step; }
double a() const { return _a; }; double a1() const { return _a1; };
double a2() const { return _a2; };
}; };
#endif #endif

View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'implicit10.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

10
is5.plt
View File

@@ -1,10 +0,0 @@
set cbrange [0:100]
set size ratio 0.8
unset key
set palette defined (0 0 0 1, 0.25 0 1 1, 0.5 0 1 0, 0.75 1 1 0, 1 1 0 0)
do for [i=0:99]{
plot 'implicit5.txt' u 1:2:3 index i w points pt 5 palette
pause 1e-09}
pause mouse

View File

@@ -9,50 +9,50 @@ double Node::T() const {
if (_btype == 2) { if (_btype == 2) {
if (!_left) if (!_left)
if (_right) if (_right)
return _right->T() / (1 + Dist(_right)); return _right->T();
if (!_right) if (!_right)
if (_left) if (_left)
return _left->T() / (1 + Dist(_left)); return _left->T();
if (!_above) if (!_above)
if (_below) if (_below)
return _below->T() / (1 + Dist(_below)); return _below->T();
if (!_below) if (!_below)
if (_above) if (_above)
return _above->T() / (1 + Dist(_above)); return _above->T();
if (_right && _left) { if (_right && _left) {
if (_right->IsBound()) if (_right->IsBound())
return _left->T() / (1 + Dist(_left)); return _left->T();
return _right->T() / (1 + Dist(_right)); return _right->T();
} }
if (_above && _below) { if (_above && _below) {
if (_above->IsBound()) if (_above->IsBound())
return _below->T() / (1 + Dist(_below)); return _below->T();
return _above->T() / (1 + Dist(_above)); return _above->T();
} }
} }
if (_btype == 3) { if (_btype == 3) {
if (!_left) if (!_left)
if (_right) if (_right)
return _right->T(); return _right->T() / (1 + Dist(_right));
if (!_right) if (!_right)
if (_left) if (_left)
return _left->T(); return _left->T() / (1 + Dist(_left));
if (!_above) if (!_above)
if (_below) if (_below)
return _below->T(); return _below->T() / (1 + Dist(_below));
if (!_below) if (!_below)
if (_above) if (_above)
return _above->T(); return _above->T() / (1 + Dist(_above));
if (_right && _left) { if (_right && _left) {
if (_right->IsBound()) if (_right->IsBound())
return _left->T(); return _left->T() / (1 + Dist(_left));
return _right->T(); return _right->T() / (1 + Dist(_right));
} }
if (_above && _below) { if (_above && _below) {
if (_above->IsBound()) if (_above->IsBound())
return _below->T(); return _below->T() / (1 + Dist(_below));
return _above->T(); return _above->T() / (1 + Dist(_above));
} }
} }

View File

@@ -1,6 +1,6 @@
#include "Solver.hpp" #include "Solver.hpp"
void Solver::SolveImplicit(System& program, double tstop) const { void Solver::SolveExplicit(System& program, double tstop) const {
std::ofstream output(filename_impl); std::ofstream output(filename_expl);
//output << "t x y T" << std::endl; //output << "t x y T" << std::endl;
for (double t = 0.0; t < tstop; t += delta) { for (double t = 0.0; t < tstop; t += delta) {
@@ -50,8 +50,8 @@ void Solver::SolveImplicit(System& program, double tstop) const {
} }
} }
void Solver::SolveExplicit(System& sys, double tstop) const { void Solver::SolveImplicit(System& sys, double tstop) const {
std::ofstream output(filename_expl); std::ofstream output(filename_impl);
//output << "t x y T" << std::endl; //output << "t x y T" << std::endl;
for (double t = 0.; t < tstop; t += delta) { for (double t = 0.; t < tstop; t += delta) {
@@ -66,7 +66,7 @@ void Solver::SolveExplicit(System& sys, double tstop) const {
double tx = (node->r()->T() - 2 * node->T() + node->l()->T()) / pow(sys.step(), 2); double tx = (node->r()->T() - 2 * node->T() + node->l()->T()) / pow(sys.step(), 2);
double ty = (node->u()->T() - 2 * node->T() + node->d()->T()) / pow(sys.step(), 2); double ty = (node->u()->T() - 2 * node->T() + node->d()->T()) / pow(sys.step(), 2);
double t = delta * (tx + ty) * sys.a() + node->T(); double t = delta * (tx + ty) + node->T();
node->SetT(t); node->SetT(t);
} }
} }
@@ -85,17 +85,17 @@ void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
/* Защита от нуля */ /* Защита от нуля */
if (mu2 == 0.) if (mu2 == 0.)
mu2 = .1; mu2 = .1;
double val2 = -(2 * sys.a()) / (pow(sys.step(), 2)) - 1 / delta; double val2 = -(2 * sys.a1()) / (pow(sys.step(), 2)) - 1 / delta;
double val1 = sys.a() / (pow(sys.step(), 2)); double val1 = sys.a1() / (pow(sys.step(), 2));
std::vector<std::vector<double>> _Temperature(size); std::vector<std::vector<double>> _Temperature(size);
std::vector<double> right(size); std::vector<double> right(size);
for (int i = 0; i < _Temperature.size(); i++) for (int i = 0; i < _Temperature.size(); i++)
_Temperature[i].resize(3, 0.0); _Temperature[i].resize(3, 0.0);
_Temperature[0][0] = -(2 * sys.a()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */ _Temperature[0][0] = -(2 * sys.a1()) / (mu1 * pow(sys.step(), 2)) - 1 / delta; /* Первый узел по X */
_Temperature[0][1] = (2 * sys.a()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */ _Temperature[0][1] = (2 * sys.a1()) / ((mu1 + 1) * pow(sys.step(), 2)); /* Первый узел по Y */
_Temperature.back()[1] = (2 * sys.a()) / ((mu2 + 1) * pow(sys.step(), 2)); _Temperature.back()[1] = (2 * sys.a1()) / ((mu2 + 1) * pow(sys.step(), 2));
_Temperature.back()[2] = -(2 * sys.a()) / (mu2 * pow(sys.step(), 2)) - 1 / delta; _Temperature.back()[2] = -(2 * sys.a1()) / (mu2 * pow(sys.step(), 2)) - 1 / delta;
for (int i = 1; i < size - 1; i++) { for (int i = 1; i < size - 1; i++) {
_Temperature[i][0] = val1; _Temperature[i][0] = val1;
@@ -105,8 +105,8 @@ void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
for (int i = 0; i < right.size(); i++) for (int i = 0; i < right.size(); i++)
right[i] = -n[i + 1]->T() / delta; right[i] = -n[i + 1]->T() / delta;
right.front() += -(2 * sys.a() * n.front()->T()) / (mu1 * (mu1 + 1) * pow(sys.step(), 2)); right.front() += -(2 * sys.a1() * n.front()->T()) / (mu1 * (mu1 + 1) * pow(sys.step(), 2));
right.back() += -(2 * sys.a() * n.back()->T()) / (mu2 * (mu2 + 1) * pow(sys.step(), 2)); right.back() += -(2 * sys.a1() * n.back()->T()) / (mu2 * (mu2 + 1) * pow(sys.step(), 2));
std::vector<double> tmps = ThomasMethod(_Temperature, right); std::vector<double> tmps = ThomasMethod(_Temperature, right);
for (int i = 0; i < tmps.size(); i++) for (int i = 0; i < tmps.size(); i++)
n[i + 1]->SetT(tmps[i]); n[i + 1]->SetT(tmps[i]);

View File

@@ -17,7 +17,7 @@
#define HOLE_Y 255. #define HOLE_Y 255.
#define HOLE_RADIUS 50. #define HOLE_RADIUS 50.
#define CONDUCTIVITY 90. // Теплопроводность материала #define CONDUCTIVITY 50. // Теплопроводность материала
void visualize(std::ofstream& file, std::string filename, int time_end) { void visualize(std::ofstream& file, std::string filename, int time_end) {
file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl; file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl;
@@ -36,12 +36,12 @@ int main()
3 - конвекция 3 - конвекция
4 - отсутствует 4 - отсутствует
*/ */
int left = 1; int left = 3;
int top = 3; int top = 1;
int right = 1; int right = 3;
int bottom = 3; int bottom = 1;
int arc_bound = 3; int arc_bound = 3;
int hole_bound = 2; int hole_bound = 1;
double step_5 = 5; double step_5 = 5;
double step_10 = 10; double step_10 = 10;
@@ -83,19 +83,19 @@ int main()
slv10.SolveExplicit(explicit10, time_end); slv10.SolveExplicit(explicit10, time_end);
slv10.SolveImplicit(implicit10, time_end); slv10.SolveImplicit(implicit10, time_end);
std::ofstream script("es10.plt"); std::ofstream script("ixplicit10.plt");
visualize(script, "explicit10.txt", time_end); visualize(script, "explicit10.txt", time_end);
script.close(); script.close();
script.open("is10.plt"); script.open("implicit10.plt");
visualize(script, "implicit10.txt", time_end); visualize(script, "implicit10.txt", time_end);
script.close(); script.close();
script.open("es5.plt"); script.open("explicit5.plt");
visualize(script, "explicit5.txt", time_end); visualize(script, "explicit5.txt", time_end);
script.close(); script.close();
script.open("is5.plt"); script.open("explicit5.plt");
visualize(script, "implicit5.txt", time_end); visualize(script, "implicit5.txt", time_end);
script.close(); script.close();
return 0; return 0;