Reformat ipynb + new rules for gitignore

This commit is contained in:
2025-09-25 01:38:30 +03:00
parent b8bc3f705a
commit cac280deb1
3 changed files with 59 additions and 20 deletions

3
.gitignore vendored
View File

@@ -636,4 +636,7 @@ FodyWeavers.xsd
*.msix *.msix
*.msm *.msm
*.msp *.msp
*.txt *.txt
!CMakeLists.txt
*.png

View File

@@ -2,13 +2,13 @@
class Solver { class Solver {
private: private:
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> // Коэффициенты в ДУ
double A, B, C, D; double A, B, C, D;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // Длина конечного элемента
double L; double L;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // Количество конечных элементов
int N; int N;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> // Границы частного решения ДУ
int upper, lower; int upper, lower;
public: public:
Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u); Solver(double _A, double _B, double _C, double _D, int _N, int _l, int _u);

View File

@@ -8,6 +8,34 @@
"# Solution of second-order linear ordinary differential equation" "# 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", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -37,7 +65,7 @@
"id": "8af07a56", "id": "8af07a56",
"metadata": {}, "metadata": {},
"source": [ "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", "id": "efac514a",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Linear element" "### Linear element"
] ]
}, },
{ {
@@ -78,8 +106,8 @@
" plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n", " plt.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
" plt.title(f\"Linear element, elements = {elements}\")\n", " plt.title(f\"Linear element, elements = {elements}\")\n",
" plt.grid(True)\n", " plt.grid(True)\n",
" plt.xlabel(\"X\")\n", " plt.xlabel(\"x\")\n",
" plt.ylabel(\"Y\")\n", " plt.ylabel(\"u(x)\")\n",
" plt.legend()\n", " plt.legend()\n",
" plt.savefig(f\"linear_{elements}.png\", dpi=300)\n", " plt.savefig(f\"linear_{elements}.png\", dpi=300)\n",
" plt.show()\n", " plt.show()\n",
@@ -92,7 +120,7 @@
"id": "d9a38740", "id": "d9a38740",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Cubic element" "### Cubic element"
] ]
}, },
{ {
@@ -110,11 +138,11 @@
" y = np.fromstring(data_str, sep=' ')\n", " y = np.fromstring(data_str, sep=' ')\n",
" y_real = u(x)\n", " y_real = u(x)\n",
"\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.plot(x, y_real, label=\"Numeral solution\", color='black')\n",
" plt.title(f\"Cubic element, elements = {elements} \")\n", " plt.title(f\"Cubic element, elements = {elements} \")\n",
" plt.xlabel(\"X\")\n", " plt.xlabel(\"x\")\n",
" plt.ylabel(\"Y\")\n", " plt.ylabel(\"u(x)\")\n",
" plt.grid(True)\n", " plt.grid(True)\n",
" plt.legend()\n", " plt.legend()\n",
" plt.savefig(f\"cubic_{elements}.png\", dpi=300)\n", " plt.savefig(f\"cubic_{elements}.png\", dpi=300)\n",
@@ -138,9 +166,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"N = 20\n", "show_plot_linear(linear_file, N)\n",
"show_plot_linear(\"matrix_linear.txt\", N)\n", "show_plot_cubic(cubic_file, N)"
"show_plot_cubic(\"matrix_cubic.txt\", N)"
] ]
}, },
{ {
@@ -154,7 +181,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "e0e9266d", "id": "31de1104",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -162,8 +189,16 @@
" with open(filename, 'r') as file:\n", " with open(filename, 'r') as file:\n",
" content = file.read().strip()\n", " content = file.read().strip()\n",
" data = np.array([float(x) for x in content.split()])\n", " data = np.array([float(x) for x in content.split()])\n",
" return data\n", " return data"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0e9266d",
"metadata": {},
"outputs": [],
"source": [
"def show_error(program_file: str, analytical_file: str):\n", "def show_error(program_file: str, analytical_file: str):\n",
" # Считывание данных из файлов\n", " # Считывание данных из файлов\n",
" real = read_data_from_file(analytical_file)\n", " real = read_data_from_file(analytical_file)\n",
@@ -192,13 +227,14 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "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": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": ".venv", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },