mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
138 KiB
138 KiB
In [33]:
import numpy as np
import matplotlib.pyplot as plt
import pyvista as pv
from pyvista.trame.jupyter import launch_server
await launch_server().ready
Out [33]:
True
In [39]:
mesh = pv.read('electric_field.vtk')
mesh2 = pv.read("density.vtk")
mesh.plot()
meshOut [39]:
Widget(value='<iframe src="http://localhost:39299/index.html?ui=P_0x78816c2c7c50_5&reconnect=auto" class="pyvi…
| Header | Data Arrays | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
In [44]:
arr_x = np.array(mesh.point_data["x_coordinate"])
arr_e_field = np.array(mesh.point_data["electric_field"])[:,0]
arr_potential = np.array(mesh.point_data["potential"])
arr_density = np.array(mesh2.point_data["density"])
# Electric field plot
plt.figure(figsize=(7, 4))
plt.scatter(arr_x, arr_e_field, s=15, alpha=0.7)
plt.xlabel("x")
plt.ylabel("E(x)")
plt.title("Electric Field")
plt.grid(True, linestyle="--", linewidth=0.5, alpha=0.6)
plt.tight_layout()
plt.show()
# Potential plot
plt.figure(figsize=(7, 4))
plt.scatter(arr_x, arr_potential, s=15, alpha=0.7)
plt.xlabel("x")
plt.ylabel("Potential")
plt.title("Electric Potential")
plt.grid(True, linestyle="--", linewidth=0.5, alpha=0.6)
plt.tight_layout()
plt.show()
# Potential plot
plt.figure(figsize=(7, 4))
plt.scatter(arr_x, arr_density, s=15, alpha=0.7)
plt.xlabel("x")
plt.ylabel(r"$\rho(x)$")
plt.title("Charge Density")
plt.grid(True, linestyle="--", linewidth=0.5, alpha=0.6)
plt.tight_layout()
plt.show()In [ ]: