Datasets:
File size: 6,112 Bytes
e75efae 0e57b0f e75efae 74c72c1 e75efae 045f29c 74c72c1 045f29c e75efae 0e57b0f e75efae 0e57b0f e75efae 0e57b0f e75efae 0e57b0f e75efae 74c72c1 e75efae 74c72c1 e75efae 74c72c1 e75efae 74c72c1 e75efae 74c72c1 e75efae 74c72c1 e75efae 74c72c1 e75efae 0e57b0f e75efae 74c72c1 e75efae 74c72c1 e75efae 0e57b0f e75efae 0e57b0f e75efae 0e57b0f e75efae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from fsi_reader import FsiDataReader\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from matplotlib.tri import Triangulation\n",
"from matplotlib.animation import FuncAnimation\n",
"from scipy.interpolate import griddata\n",
"from plotting import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading and Visualizing the Dataset\n",
"\n",
"In this section, we will explore how to load the fluid-solid interaction simulation dataset and visualize it.\n",
"\n",
"We will specifically load the simulation data for \\( \\mu = 1.0 \\), where the inlet parameter \\( x_1 = 0.0 \\) and the all inlet parameters for \\( x_2 \\) will be considered as provided in the dataset.\n",
"\n",
"Let's begin by loading the data and visualizing it to better understand its structure and behavior.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = FsiDataReader('./fsi-data/', mu=['1.0'], in_lets_x1=['0.0'])\n",
"mesh = data.input_mesh\n",
"print(mesh.shape)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_loader = data.get_loader(batch_size=1, shuffle=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualization\n",
"\n",
"In this section, we will visualize the pressure field from the fluid-solid interaction simulation dataset.\n",
"\n",
"### **Loaded Variables**\n",
"The dataset includes the following variables for each time step `t`:\n",
"\n",
"- `vx`, `vy`: The velocity components in the `x` and `y` directions, respectively.\n",
"- `P`: The pressure field.\n",
"- `dx`, `dy`: The displacement components in the `x` and `y` directions, respectively.\n",
"\n",
"These variables are loaded and will be used to generate the visualizations.\n",
"\n",
"### **Mesh Update**\n",
"The mesh, initially given as a 2D grid, is updated at each time step based on the displacement field. Specifically, the updated mesh at time `t` is:\n",
"\n",
"`M_t = M_0 + d_t`\n",
"\n",
"where `M_0` is the initial mesh, and `d_t` represents the displacement at time `t`.\n",
"\n",
"### **Pressure Field Visualization**\n",
"Now, we will visualize the pressure field `P_t` overlaid on the updated mesh at each time step. This will help us understand how the pressure evolves and interacts with the deformed mesh over time.\n",
"\n",
"Let's begin by plotting the pressure field and the updated mesh to observe their changes visually.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"frames = 200\n",
"data_list = []\n",
"mesh_list = []\n",
"for idx, (i,j) in enumerate(data_loader):\n",
" if idx%10 !=0:\n",
" continue\n",
" updated_mesh = mesh + i[0,:,-2:]\n",
" data_list.append(i[:,:,2].numpy()) \n",
" mesh_list.append(updated_mesh.numpy())\n",
" frames -= 1\n",
" if frames == 0:\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"create_field_animation(data_list, mesh_list, interval=100, save_path='fsi_animation_pressue.gif')"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"torch.Size([1317, 2])\n",
"file not found for mu=1.0, x1=0.0, x2=-4.0\n",
"file not found for mu=1.0, x1=0.0, x2=-2.0\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"file not found for mu=10.0, x1=0.0, x2=-4.0\n",
"file not found for mu=10.0, x1=0.0, x2=-2.0\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 1])\n",
"Loaded tensor Size: torch.Size([1001, 1317, 3])\n"
]
}
],
"source": [
"data = FsiDataReader('./fsi-data/', mu=['1.0', '10.0'], in_lets_x1=['0.0'])\n",
"mesh = data.input_mesh\n",
"print(mesh.shape)\n",
"data_loader = data.get_loader(batch_size=1, shuffle=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "neuralop",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|