Coverage for pyrc \ validation \ coupling \ comparison.py: 0%
22 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-13 16:59 +0200
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-13 16:59 +0200
1# -------------------------------------------------------------------------------
2# Copyright (C) 2026 Joel Kimmich, Tim Jourdan
3# ------------------------------------------------------------------------------
4# License
5# This file is part of PyRC, distributed under GPL-3.0-or-later.
6# ------------------------------------------------------------------------------
8# Script for validation
9#
10# Calculation of the dynamic solution of two coupled volumes with different temperature
11#
12# Comparison
13#
14import os
16import numpy as np
18from pyrc.visualization.plot import LinePlot
19from pyrc.validation.coupling.analytic import run_coupling_analytic
20from pyrc.validation.coupling.model import run_coupling_model
22if __name__ == "__main__":
23 save_folder = r"C:\Simulations\PyRC\evaluation\coupling"
24 model_x, model_y, times, name_add_on, network = run_coupling_model(os.path.join(save_folder, "coupling_model.svg"))
25 analytic_x, analytic_y, _, _ = run_coupling_analytic(
26 os.path.join(save_folder, "coupling_analytic.svg"), n_terms=10000
27 )
29 plot = LinePlot(
30 x=model_x,
31 ys=model_y - analytic_y,
32 labels=[f"{float(t):.1f} s" for t in times],
33 y_title="Temperature-Delta / K",
34 x_title="Length / m",
35 width_mm=160,
36 height_mm=90,
37 )
38 plot.plot()
40 # Add tolerance of solver as line
41 y_solver = np.max(
42 network.settings.solve_settings.atol + network.settings.solve_settings.rtol * abs(model_y), axis=0
43 )
44 plot.plot(model_x, ys=[y_solver], labels=["min solver accuracy"])
46 plot.ax.set_xlim(left=0, right=model_x[-1])
47 plot.fig.legend(loc="outside upper right", ncols=5)
48 plot.save(os.path.join(save_folder, f"coupling_comparison{name_add_on}_add.png"))
49 plot.save(os.path.join(save_folder, f"coupling_comparison{name_add_on}_add.svg"))
51 upper_limit = y_solver[int(len(y_solver) / 2)] * 1.5
52 plot.ax.set_ylim(top=upper_limit, bottom=-1 * upper_limit)
53 plot.fig.legend(loc="outside upper right", ncols=5)
54 plot.save(os.path.join(save_folder, f"coupling_comparison{name_add_on}_add_2.png"))
55 plot.save(os.path.join(save_folder, f"coupling_comparison{name_add_on}_add_2.svg"))
56 # plot.ax.set_xlim(left=0, right=model_x[-1])
57 # plot.ax.set_ylim(bottom=-0.05, top=0.05)
58 # plot.fig.legend(loc="outside upper right", ncols=5)
59 # plot.save(r"C:\Simulations\PyRC\debug\coupling_comparison2"
60 # f"{name_add_on}.png")
61 # plot.ax.set_xlim(left=0, right=0.2)
62 # plot.ax.set_ylim(bottom=-0.05, top=0.05)
63 # plot.fig.legend(loc="outside upper right", ncols=5)
64 # plot.save(r"C:\Simulations\PyRC\debug\coupling_comparison3"
65 # f"{name_add_on}.png")
66 # plot.ax.set_xlim(left=0, right=0.1)
67 # plot.ax.set_ylim(bottom=-0.05, top=0.05)
68 # plot.fig.legend(loc="outside upper right", ncols=5)
69 # plot.save(r"C:\Simulations\PyRC\debug\coupling_comparison4"
70 # f"{name_add_on}.png")