Repository navigation
Live-info channel like mumax3's web UI #152
Replies: 1 comment 2 replies
|
Hi, I agree with your sentiment and find this very useful myself, but a live GUI is not supported out of the box. It would be quite a lot of work throughout the whole code to make this feature robust, efficient and compatible with all types of output, especially on remote machines. We are not planning to spend time on this right now. However, if you are a bit proficient with Python, matplotlib and mumax+, you can probably make something to suit your specific needs. For example, let's say we are looking at standard problem 4. from mumaxplus import World, Grid, Ferromagnet
import numpy as np
import matplotlib.pyplot as plt
length, width, thickness = 500e-9, 125e-9, 3e-9
nx, ny, nz = 128, 32, 1
world = World(cellsize=(length / nx, width / ny, thickness / nz))
magnet = Ferromagnet(world, Grid((nx, ny, nz)))
magnet.msat = 800e3
magnet.aex = 13e-12
magnet.alpha = 0.02
magnet.magnetization = (1, 0.1, 0)
magnet.minimize()
B1 = (-24.6e-3, 4.3e-3, 0)
B2 = (-35.5e-3, -6.3e-3, 0)
world.bias_magnetic_field = B1 # choose B1 or B2 hereWe are then able to set up some plotting code and update that live. Here I will look at the # example quantities to look at
vec_qty = magnet.magnetization
sca_qty = magnet.exchange_energy_density
# Initialize figure and axes
fig, (vec_ax, sca_ax) = plt.subplots(nrows=2)
fig.suptitle(f"t = {world.timesolver.time * 1e9:.6f} ns")
# --- Initialize images ---
# vector image
def qty_to_rgb(qty, layer=0):
return np.transpose(qty.get_rgb()[:,layer,:,:], axes=[1,2,0])
vec_im = vec_ax.imshow(qty_to_rgb(vec_qty), origin="lower")
# scalar image
layer, comp = 0, 0
field = sca_qty.eval()[comp,layer,:,:]
vmax = np.abs(field).max()
vmin = -vmax
sca_im = sca_ax.imshow(field)
sca_im = sca_ax.imshow(field, origin="lower", cmap="seismic", vmin=vmin, vmax=vmax)
# -------------------------
plt.show(block=False)Now we can run the def update_images():
# vector
vec_im.set_data(qty_to_rgb(vec_qty))
# scalar
field = sca_qty.eval()[comp,layer,:,:]
sca_im.set_data(field)
vmax = np.abs(field).max()
vmin = -vmax
sca_im.set_clim(vmin=vmin, vmax=vmax)
# run while updating images
total_runtime = 1e-9
runtime_per_frame = 1e-11
pause = 0.01 # allow time to draw
timepoints = np.arange(0, total_runtime + runtime_per_frame, runtime_per_frame)
for t in timepoints:
dt = t - world.timesolver.time
world.timesolver._impl.run(dt) # avoid resetting sensible timestep
fig.suptitle(f"t = {world.timesolver.time * 1e9:.3f} ns")
update_images()
fig.canvas.draw()
plt.pause(pause)You could for example also use A few months ago, I made a slightly more general version of the idea above and made it as a |
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I am very much impressed by and happy with the new possibilities offered by mumax+. As a heavy user of mumax3 I found the live display of any field (most important the magnetization of course) during the computation very useful. It allows to get some feeling of what is actually going on in the simulation. Starting to use mumax+ I do miss this feature. Is it possible to get similar live info from mumax+ as with mumax3?
All reactions