@@ -12,13 +12,18 @@ to user input. It requires the Python module *PyOpenGL*.
12
12
It is not meant to produce high quality renderings, but rather to
13
13
debug the simulation setup and equilibration process.
14
14
15
+ .. _OpenGL visualizer :
16
+
17
+ OpenGL visualizer
18
+ -----------------
19
+
15
20
.. _General usage :
16
21
17
22
General usage
18
- -------------
23
+ ~~~~~~~~~~~~~
19
24
20
25
The recommended usage is to instantiate the visualizer and pass it the
21
- :class: `espressomd.System() <espressomd. system.System> ` object. Then write
26
+ :class: `~ espressomd.system.System ` object. Then write
22
27
your integration loop in a separate function, which is started in a
23
28
non-blocking thread. Whenever needed, call ``update() `` to synchronize
24
29
the renderer with your system. Finally start the blocking visualization
@@ -50,7 +55,7 @@ window with ``start()``. See the following minimal code example::
50
55
.. _Setting up the visualizer :
51
56
52
57
Setting up the visualizer
53
- -------------------------
58
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
54
59
55
60
:class: `espressomd.visualization.openGLLive() `
56
61
@@ -81,7 +86,6 @@ live plotting (see sample script :file:`/samples/visualization_ljliquid.py`).
81
86
default package manager of your operating system. On Ubuntu the required package is called ``libgle3-dev ``,
82
87
on Fedora ``libgle `` -- just to name two examples.
83
88
84
-
85
89
.. _Running the visualizer :
86
90
87
91
Running the visualizer
@@ -292,10 +296,88 @@ With the keyword ``drag_enabled`` set to ``True``, the mouse can be used to
292
296
exert a force on particles in drag direction (scaled by ``drag_force `` and the
293
297
distance of particle and mouse cursor).
294
298
299
+ .. _ZnDraw :
300
+
301
+ ZnDraw visualizer
302
+ -----------------
303
+
304
+ |es | supports the ZnDraw visualizer :cite: `elijosius24a ` in Jupyter Notebooks.
305
+ With ZnDraw [1 ]_, you can visualize your simulation live in a notebook or
306
+ web browser. The visualizer is based on ``THREE.js ``.
307
+
308
+ .. _ZnDraw General usage :
309
+
310
+ General usage
311
+ ~~~~~~~~~~~~~
312
+
313
+ The recommended usage is to instantiate the visualizer :class: `espressomd.zn.Visualizer ` and pass it the :class: `~espressomd.system.System ` object.
314
+ With the initialization you can also assign all particle types a color and radii through a type mapping. There are standard
315
+ colors like ``red ``, ``black `` etc., but one can also use hex colors like ``#ff0000 ``. The radii can be set to a float value.
316
+ Then write your integration loop in a separate function, and call the update function of the visualizer to capture
317
+ the current state of the system and visualize it. Note that the visualizer needs to be started by pressing space.
318
+
319
+ Example code::
320
+
321
+ import espressomd
322
+ import espressomd.zn
323
+
324
+ system = espressomd.System(box_l=[10, 10, 10])
325
+ system.cell_system.skin = 0.4
326
+ system.time_step = 0.001
327
+
328
+ system.part.add(pos=[1, 1, 1], v=[1, 0, 0])
329
+ system.part.add(pos=[9, 9, 9], v=[0, 1, 0])
330
+
331
+ vis = espressomd.zn.Visualizer(system, colors={0: "red"}, radii={0: 0.5})
332
+
333
+ for i in range(1000):
334
+ system.integrator.run(25)
335
+ vis.update()
336
+
337
+ The visualizer supports further features like bonds, constraints, folding and lattice-Boltzmann solvers. The particle coordinates
338
+ can be folded by initalizing the visualizer with the keyword ``folded=True ``. The display of bonds can be enabled by setting
339
+ ``bonds=True ``.
340
+
341
+ Constraints can be drawn using the :meth: `~espressomd.zn.Visualizer.draw_constraints ` method.
342
+ The method takes a list of all ESPResSo shapes that should be drawn as an argument.
343
+
344
+ Furthermore the visualizer supports the visualization of the lattice-Boltzmann solver. The lattice-Boltzmann solver can be visualized
345
+ by setting the keyword ``vector_field `` to a lattice-Boltzmann solver :class: `~espressomd.zn.LBField ` object, which has to be created
346
+ before initializing the visualizer and takes in several parameters like the node spacing, node offset and scale. One can also apply a
347
+ color map to the vector field by setting the keyword ``arrow_config `` to a dictionary containing the arrow settings.
348
+
349
+ The arrow config contains a ``colormap `` using a list of 2 HSL-color values from which vector colors are interpolated using their length
350
+ as a criterium. The ``normalize `` boolean which normalizes the color to the largest vector. The ``colorrange `` list which is only used when
351
+ ``normalize `` is false and describes the range to what the colorrange is applied to. ``scale_vector_thickness `` is a boolean and changes
352
+ the thickness scaling of the vectors and ``opacity `` is a float value that sets the opacity of the vectors.
353
+
354
+ An example code snippet containing the :class: `~espressomd.zn.LBField ` object::
355
+
356
+ import espressomd.zn
357
+
358
+ color = {0: "#00f0f0"}
359
+ radii = {0: 0.5}
360
+ arrows_config = {'colormap': [[-0.5, 0.9, 0.5], [-0.0, 0.9, 0.5]],
361
+ 'normalize': True,
362
+ 'colorrange': [0, 1],
363
+ 'scale_vector_thickness': True,
364
+ 'opacity': 1.0}
365
+
366
+ lbfield = espressomd.zn.LBField(system, step_x=2, step_y=2, step_z=5, scale=1)
367
+ vis = espressomd.zn.Visualizer(system, colors=color, radii=radii, folded=True,
368
+ vector_field=lbfield)
369
+
370
+ vis.draw_constraints([wall1, wall2])
371
+
295
372
.. _Visualization example scripts :
296
373
297
374
Visualization example scripts
298
375
-----------------------------
299
376
300
377
Various :ref: `Sample Scripts ` can be found in :file: `/samples/visualization_*.py `
301
378
or in the :ref: `Tutorials ` "Visualization" and "Charged Systems".
379
+
380
+ ____
381
+
382
+ .. [1 ]
383
+ https://github.com/zincware/ZnDraw
0 commit comments