Skip to content
Snippets Groups Projects
Commit 2118fd1e authored by Koerber, Lukas (FWIN-C) - 108045's avatar Koerber, Lukas (FWIN-C) - 108045
Browse files

Change show_Bext() to show() and to some cosmetics.

parent cd4fa4e3
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ from ..experiments.calculate_absorption import calculate_absorption
from ..helpers.math import h_U, h_hom, h_CPW, h_strip
import pygmsh
B_ext_color = 0xED4B42
class ExperimentalSetup:
......@@ -33,36 +34,43 @@ class ExperimentalSetup:
print("You are trying to set an external field which does not match the shape of the mesh.")
def show_Bext(self, comp="vec", scale=5):
if np.any(self._Bext) == 0:
print("External field is zero.")
else:
def show(self, comp="vec", scale=5, show_antenna=True):
plot = k3d.plot()
plt_mesh = k3d.mesh(np.float32(self.sample.mesh.points), np.uint32(self.sample.mesh.get_cells_type("triangle")))
plt_mesh.wireframe = True
plt_mesh.color = 0xaaaaaa
plt_mesh.opacity = 1
plot += plt_mesh
if np.any(self._Bext) != 0:
hx = self._Bext.T[0]
hy = self._Bext.T[1]
hz = self._Bext.T[2]
colors = np.repeat(np.array([(np.uint32(B_ext_color), np.uint32(B_ext_color))]),self.sample.nx)
if comp=="vec":
m_mesh = k3d.vectors(np.float32(self.sample.mesh.points), np.float32(scale*(np.vstack([hx, hy, hz] )).T), head_size=2.5*scale,line_width=0.05*scale)
m_mesh = k3d.vectors(np.float32(self.sample.mesh.points), np.float32(scale*(np.vstack([hx, hy, hz] )).T), head_size=2.5*scale,line_width=0.05*scale,colors=colors)
else:
comp_dict = {"x": hx, "y": hy, "z" : hz, "phi" : np.arctan2(hy,hx), "abs" : np.sqrt(hx**2 + hy**2 + hz**2)}
color_dict = {"abs" : k3d.colormaps.matplotlib_color_maps.Inferno,"x": k3d.colormaps.matplotlib_color_maps.RdBu, "y": k3d.colormaps.matplotlib_color_maps.RdBu, "z" : k3d.colormaps.matplotlib_color_maps.RdBu, "phi" : k3d.colormaps.matplotlib_color_maps.Twilight_shifted}
# TODO check if comp is valid key
m_mesh = k3d.mesh(np.float32(self.sample.mesh.points), np.uint32(self.sample.mesh.get_cells_type("triangle")),attribute=comp_dict[comp],color_map=color_dict[comp],interpolation=False, side="double", flat_shading=True, name="$m_{{}}$".format(comp))
plot = k3d.plot()
plt_mesh = k3d.mesh(np.float32(self.sample.mesh.points), np.uint32(self.sample.mesh.get_cells_type("triangle")))
plt_mesh.wireframe = True
plt_mesh.color = 0xaaaaaa
plt_mesh.opacity = 0.1
plot += m_mesh
plot += plt_mesh
if self._antenna is not None:
span = np.max(np.abs(self.sample.xyz.T[0]))*2
antenna_mesh = self._antenna.get_mesh(span)
plot += k3d.mesh(np.float32(antenna_mesh.points), np.uint32(antenna_mesh.get_cells_type("triangle")),color=0xFFD700, side="double")
plot.display()
else:
anchor = 1.5* np.max(self.sample.xyz)
plt_text = k3d.text2d('B_{ext} = 0',
position=[0,0],
color=B_ext_color, size=1)
plot += plt_text
if self._antenna is not None and show_antenna:
span = np.max(np.abs(self.sample.xyz.T[0]))*2
antenna_mesh = self._antenna.get_mesh(span)
plot += k3d.mesh(np.float32(antenna_mesh.points), np.uint32(antenna_mesh.get_cells_type("triangle")),color=0xFFD700, side="double")
plot.display()
def relax(self, tol=1e-12):
# TODO check if sample has magnetization
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment