AtomsView

AtomsView is a package of tools for visualising AtomsBase-compatible structures. The functionality is still limited and interfaces unstable. Expect them to change at any time.

AtomsView.drawsystemFunction
drawsystem(system; kwargs...)
drawsystem!(f, system; kwargs...)

Draw a AtomsBase AbstractSystem.

You can also give kwargs that Makies meshscatter supports.

Kwords

  • draw_cell=false : draw cell
  • cell_color=:black : cell color
  • scale=1.0 : Scale atom sizes

Examples

Draw a system

using GLMakie
using AtomsBuilder
using AtomsView

system = bulk(:Cu) * (4,4,4)

f = drawsystem(system; draw_cell=true, scale=1.0, cell_color=:black)

# set atoms sizes to 70% of Van der Waals sizes
f.plot.scale[] = 0.7

# set cell color to teal
f.plot.cell_color[] = :teal

# hide cell
f.plot.draw_cell[] = false

# draw to to existing figure
# hide axis and use black background
fig = Figure()
lsc = LScene(fig[1,1]; show_axis=false, scenekw = (backgroundcolor=:black, clear=true) )
drawsystem!(lsc, system)

Draw trajectory

using GLMakie
using AtomsBase
using AtomsBuilder
using AtomsView

traj = map( 1:10 ) do d 
    FastSystem( rattle!(bulk(:Cu) * (4,4,4), 0.1*d) )
end

# Draw first frame from traj
t = Observable(traj[1])
f = drawsystem(t; draw_cell=true)

# set figure to traj[7]
t[] = traj[7]

Known issues

  1. When changing the system to a system with more atoms, some of the atoms will not be drawn. This is a bug in Makie. You can work around this by creating the figure by starting with the system with the most atoms.

  2. If you use subfigure as an input to drawsystem!, the plot can crash.

fig = Figure()
drawsystem!(fig[1,1], sys) # this fails

Use LScene instead

fig = Figure()
sc  = LScene(fig[1,1])
drawsystem!(sc, sys) # this works
source
AtomsView.drawsystem!Function
drawsystem(system; kwargs...)
drawsystem!(f, system; kwargs...)

Draw a AtomsBase AbstractSystem.

You can also give kwargs that Makies meshscatter supports.

Kwords

  • draw_cell=false : draw cell
  • cell_color=:black : cell color
  • scale=1.0 : Scale atom sizes

Examples

Draw a system

using GLMakie
using AtomsBuilder
using AtomsView

system = bulk(:Cu) * (4,4,4)

f = drawsystem(system; draw_cell=true, scale=1.0, cell_color=:black)

# set atoms sizes to 70% of Van der Waals sizes
f.plot.scale[] = 0.7

# set cell color to teal
f.plot.cell_color[] = :teal

# hide cell
f.plot.draw_cell[] = false

# draw to to existing figure
# hide axis and use black background
fig = Figure()
lsc = LScene(fig[1,1]; show_axis=false, scenekw = (backgroundcolor=:black, clear=true) )
drawsystem!(lsc, system)

Draw trajectory

using GLMakie
using AtomsBase
using AtomsBuilder
using AtomsView

traj = map( 1:10 ) do d 
    FastSystem( rattle!(bulk(:Cu) * (4,4,4), 0.1*d) )
end

# Draw first frame from traj
t = Observable(traj[1])
f = drawsystem(t; draw_cell=true)

# set figure to traj[7]
t[] = traj[7]

Known issues

  1. When changing the system to a system with more atoms, some of the atoms will not be drawn. This is a bug in Makie. You can work around this by creating the figure by starting with the system with the most atoms.

  2. If you use subfigure as an input to drawsystem!, the plot can crash.

fig = Figure()
drawsystem!(fig[1,1], sys) # this fails

Use LScene instead

fig = Figure()
sc  = LScene(fig[1,1])
drawsystem!(sc, sys) # this works
source
AtomsView.visualize_structureMethod

Produce some text/html code which allows to interactively view the system. Currently uses Bio3DView and some kwargs can be used to customise the representation. Note that the backend as well as interface is likely going to change in the future.

source