aiida_spirit.tools package

Submodules

aiida_spirit.tools._vfr module

Interface to the spirit web view used in the plotting tool.

aiida_spirit.tools._vfr.setup(vfr_frame_id='', height_px=600, width_percent=100)[source]

Create a frame in the jupyter ntoebook to into which the spins are shown.

aiida_spirit.tools._vfr.update(positions, directions, rectilinear=True, vfr_frame_id='')[source]

Update the spins in the frame.

aiida_spirit.tools.get_from_remote module

Tools to get files from the remote folder

aiida_spirit.tools.get_from_remote.get_file_content_from_remote(node, fname)[source]

copy a text file from the remote to a temporary dir and load it from there

aiida_spirit.tools.get_from_remote.list_remote_files(node)[source]

Open an ssh connection and return the list of files in the remote

aiida_spirit.tools.helpers module

Helper functions for automatically setting up computer & code. Helper functions for setting up

  1. An AiiDA localhost computer

  2. A “spirit” code on localhost

aiida_spirit.tools.helpers.get_code(entry_point, computer)[source]

Get local code. Sets up code for given entry point on given computer.

Parameters:
  • entry_point – Entry point of calculation plugin

  • computer – (local) AiiDA computer

Returns:

The code node

Return type:

aiida.orm.Code

aiida_spirit.tools.helpers.get_computer(name='localhost-test', workdir=None)[source]

Get AiiDA computer. Loads computer ‘name’ from the database, if exists. Sets up local computer ‘name’, if it isn’t found in the DB.

Parameters:
  • name – Name of computer to load or set up.

  • workdir – path to work directory Used only when creating a new computer.

Returns:

The computer node

Return type:

aiida.orm.Computer

aiida_spirit.tools.helpers.get_path_to_executable(executable)[source]

Get path to local executable. :param executable: Name of executable in the $PATH variable :type executable: str :return: path to executable :rtype: str

aiida_spirit.tools.helpers.prepare_test_inputs(input_dir)[source]

Prepare the input parameters, structure and load the Jij’s for a simple SpiritCalculation for bcc Fe,

aiida_spirit.tools.plotting module

Plotting tools for aiida-spirit.

aiida_spirit.tools.plotting._plot_spins_vfr(pos_cell, n_basis_cells, cell, spin_directions, scale_spins=1.0, vfr_frame_id='')[source]

Construct positions and directions array and update the vfrendering spin view

aiida_spirit.tools.plotting.init_spinview(vfr_frame_id='', height_px=600, width_percent=100)[source]

Initialize the vfrendering HTML object.

Needs to be called before the show_spins function can set the spins :param vfr_frame_id: a string that controls if multiple windows should be openend. Use the same string in show_spins to update this. :param height_px: height of the window in pixels :param width_percent: window width in percent of the current width size

aiida_spirit.tools.plotting.show_spins(spirit_calc, show_final_structure=True, scale_spins=1.0, scale_lattice=1.0, list_spin_files_on_remote=False, use_remote_spins_id=None, mask=None, vfr_frame_id='')[source]

Update the vfrendering spin view plot with the final or initial spin structure.

Needs to have the init_spinview() function called to initialize a window where the plot is shown.

Parameters:
  • spirit_calc – the SpiritCalculation which is supposed to be visualized

  • show_final_structure – boolean that tells us if the initial or final structure of the spins should be displayed

  • scale_spins – a scaling factor that can be used to scale the size of the arrows

  • scale_lattice – a scaling factor that can be used to scale the spacing of the atoms

  • list_spin_files_on_remote – print a list of the available spin image files on the remote folder.

  • use_remote_spins_id – show neither final nor initial spin structure but show the structure of a certain checkpoint (see list_spin_files_on_remote=True output for available checkpoints).

  • mask – mask which can be used to hide or rescale spins (mask is multiplied to the spins, i.e. mask==0 hides a spin, mask>1 enhaces its size).

  • vfr_frame_id – if given this allows to control into which spinview frame the spins are shown. Should be the same as in the init_spinview. This is not fully implemented yet and does not work in this version.

aiida_spirit.tools.spirit_script_builder module

Helper class for builder run_spirit script.

class aiida_spirit.tools.spirit_script_builder.PythonScriptBuilder(indentation='')[source]

Bases: object

Helper class to build python scripts with correct indentation

__dict__ = mappingproxy({'__module__': 'aiida_spirit.tools.spirit_script_builder', '__doc__': 'Helper class to build python scripts with correct indentation', 'indentation': '', 'indentation_increment': '    ', '__init__': <function PythonScriptBuilder.__init__>, '__enter__': <function PythonScriptBuilder.__enter__>, '__exit__': <function PythonScriptBuilder.__exit__>, '__str__': <function PythonScriptBuilder.__str__>, '__iadd__': <function PythonScriptBuilder.__iadd__>, 'empty_line': <function PythonScriptBuilder.empty_line>, 'block': <function PythonScriptBuilder.block>, 'write': <function PythonScriptBuilder.write>, '__dict__': <attribute '__dict__' of 'PythonScriptBuilder' objects>, '__weakref__': <attribute '__weakref__' of 'PythonScriptBuilder' objects>, '__annotations__': {}})
__enter__()[source]

On entering a with clause we increase the indentation.

__exit__(exception_type, exception_value, traceback)[source]

On exiting a with clause we decrease the indentation.

__iadd__(contents)[source]
Operator += appends to script body and respects indentation.

Ignores leading empty lines. Automatically appends ‘

‘.

IMPORTANT: When appending multiline strings, make sure that the first non-empty line has a correct relative indentation to the rest of the lines. This is because the first non-empty line will be used to figure out how much leading whitespace to remove from the rest of the lines.

__init__(indentation='')[source]
__module__ = 'aiida_spirit.tools.spirit_script_builder'
__str__()[source]

String representation.

__weakref__

list of weak references to the object (if defined)

block(header)[source]

” Start a block with a header. e.g:

with s.block("for i in range(10):"):
       print(i)
empty_line()[source]

Append an empty line to the script body

indentation = ''
indentation_increment = '    '
write(file)[source]

Write script to file

class aiida_spirit.tools.spirit_script_builder.SpiritScriptBuilder(indentation='')[source]

Bases: PythonScriptBuilder

Helper class to build pyton scripts for the spirit api

__module__ = 'aiida_spirit.tools.spirit_script_builder'
static _dict_to_arg_string(dict)[source]

Format a dict as a string of keyword arguments

_method_dict = {'llg': 'simulation.METHOD_LLG', 'mc': 'simulation.METHOD_MC'}
_module_dict = {'configuration': 'configuration', 'geometry': 'geometry', 'io': 'io', 'simulation': 'simulation', 'state': 'state'}
_solver_dict = {'depondt': 'simulation.SOLVER_DEPONDT', 'heun': 'simulation.SOLVER_HEUN', 'lbfgs_atlas': 'simulation.SOLVER_LBFGS_Atlas', 'lbfgs_oso': 'simulation.SOLVER_LBFGS_OSO', 'rk4': 'simulation.SOLVER_SIB', 'sib': 'simulation.SOLVER_SIB', 'vp': 'simulation.SOLVER_VP', 'vp_oso': 'simulation.SOLVER_VP_OSO'}
_spirit_call(module, function_name, *args, **kwargs)[source]

A generic call to any of the spirit api functions.

configuration(fname, *args, **kwargs)[source]

Sets one of the configuration api functions on of p_state

import_modules(*args)[source]

Imports the modules given in *args. If no *args are given, imports all modules in the module dict

static list_to_arg_string(list)[source]

Format a list as a string of positional arguments

method(key)[source]

Set Spirit run method (i.e. LLG, MC)

module(key)[source]

Import the spirit modules

solver(key)[source]

Set spirit solver (Depodt, VP, …)

start_simulation(method, solver, *args, **kwargs)[source]

Start a simulation with a method and a solver.

state_block(input_file='input_created.cfg')[source]

Creates the state_block and thereby creates the p_state

Module contents