diff --git a/.gitignore b/.gitignore index d485aef..0b1da13 100644 --- a/.gitignore +++ b/.gitignore @@ -636,4 +636,7 @@ FodyWeavers.xsd *.msix *.msm *.msp + *.txt +!CMakeLists.txt +*.png diff --git a/Solver.h b/Solver.h index 5eca8d3..9ea0440 100644 --- a/Solver.h +++ b/Solver.h @@ -2,13 +2,13 @@ class Solver { private: - // + // Коэффициенты в ДУ double A, B, C, D; - // + // Длина конечного элемента double L; - // + // Количество конечных элементов int N; - // + // Границы частного решения ДУ int upper, lower; public: Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u); diff --git a/graphics.ipynb b/graphics.ipynb index a810903..1ae90e8 100644 --- a/graphics.ipynb +++ b/graphics.ipynb @@ -8,6 +8,34 @@ "# Solution of second-order linear ordinary differential equation" ] }, + { + "cell_type": "markdown", + "id": "a4b21c72", + "metadata": {}, + "source": [ + "## Input vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6653253d", + "metadata": {}, + "outputs": [], + "source": [ + "N = 20\n", + "linear_file = f\"matrix_linear_{N}.txt\"\n", + "cubic_file = f\"matrix_cubic_{N}.txt\"" + ] + }, + { + "cell_type": "markdown", + "id": "781047cc", + "metadata": {}, + "source": [ + "## System cells" + ] + }, { "cell_type": "code", "execution_count": null, @@ -37,7 +65,7 @@ "id": "8af07a56", "metadata": {}, "source": [ - "## Solution of $5u'' + 4u' + 1 = 0, u'(0) = u(0), u(10) = 5$" + "### Solution of $5u'' + 4u' + 1 = 0, u'(0) = u(0), u(10) = 5$" ] }, { @@ -56,7 +84,7 @@ "id": "efac514a", "metadata": {}, "source": [ - "## Linear element" + "### Linear element" ] }, { @@ -78,8 +106,8 @@ " plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n", " plt.title(f\"Linear element, elements = {elements}\")\n", " plt.grid(True)\n", - " plt.xlabel(\"X\")\n", - " plt.ylabel(\"Y\")\n", + " plt.xlabel(\"x\")\n", + " plt.ylabel(\"u(x)\")\n", " plt.legend()\n", " plt.savefig(f\"linear_{elements}.png\", dpi=300)\n", " plt.show()\n", @@ -92,7 +120,7 @@ "id": "d9a38740", "metadata": {}, "source": [ - "## Cubic element" + "### Cubic element" ] }, { @@ -110,11 +138,11 @@ " y = np.fromstring(data_str, sep=' ')\n", " y_real = u(x)\n", "\n", - " plt.plot(x, y, label=\"Cubic element solution\", color=\"green\")\n", + " plt.plot(x, y, label=\"Cubic element solution\", color=\"orange\")\n", " plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n", " plt.title(f\"Cubic element, elements = {elements} \")\n", - " plt.xlabel(\"X\")\n", - " plt.ylabel(\"Y\")\n", + " plt.xlabel(\"x\")\n", + " plt.ylabel(\"u(x)\")\n", " plt.grid(True)\n", " plt.legend()\n", " plt.savefig(f\"cubic_{elements}.png\", dpi=300)\n", @@ -138,9 +166,8 @@ "metadata": {}, "outputs": [], "source": [ - "N = 20\n", - "show_plot_linear(\"matrix_linear.txt\", N)\n", - "show_plot_cubic(\"matrix_cubic.txt\", N)" + "show_plot_linear(linear_file, N)\n", + "show_plot_cubic(cubic_file, N)" ] }, { @@ -154,7 +181,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e0e9266d", + "id": "31de1104", "metadata": {}, "outputs": [], "source": [ @@ -162,8 +189,16 @@ " with open(filename, 'r') as file:\n", " content = file.read().strip()\n", " data = np.array([float(x) for x in content.split()])\n", - " return data\n", - "\n", + " return data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e0e9266d", + "metadata": {}, + "outputs": [], + "source": [ "def show_error(program_file: str, analytical_file: str):\n", " # Считывание данных из файлов\n", " real = read_data_from_file(analytical_file)\n", @@ -192,13 +227,14 @@ "metadata": {}, "outputs": [], "source": [ - "show_error(\"matrix_linear.txt\", \"linear_real_y_20.txt\")" + "show_error(linear_file, f\"linear_real_y_{N}.txt\")\n", + "show_error(cubic_file, f\"cubic_real_y_{N}.txt\")" ] } ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" },