Configuration exporters

BaseExporter

Interface for configuration-exporting classes.

Cogli1Exporter

Export configurations to the cogli1 file format, used for visualisation purposes.

GenericOxDNAExporter

Export configurations to the oxDNA file format.

LAMMPSDataFileExporter

Export configurations to the LAMMPS data file format.

class baggianalysis.core.BaseExporter(self: baggianalysis.core.BaseExporter)None

Bases: pybind11_builtins.pybind11_object

Interface for configuration-exporting classes.

The default constructor does not take any parameters.

write(self: baggianalysis.core.BaseExporter, system: baggianalysis.core.System, filename: str)None

Print out a single system.

Parameters
  • system (System) – The System to be printed.

  • filename (str) – The name of the output file.

write_topology(self: baggianalysis.core.BaseExporter, arg0: baggianalysis.core.System, arg1: str)None

Some formats have a topology file on top of configuration (and/or trajectory) files. By default this method is called by both write() and write_topology() and hence should be extended by child classes that export to formats that use topology files.

Parameters

system

write_trajectory(self: baggianalysis.core.BaseExporter, arg0: ba::BaseTrajectory, arg1: str)None

Print out a trajectory.

Parameters

trajectory – The trajectory to be printed.

class baggianalysis.core.Cogli1Exporter(*args, **kwargs)

Bases: baggianalysis.core.BaseExporter

Export configurations to the cogli1 file format, used for visualisation purposes.

Overloaded function.

  1. __init__(self: baggianalysis.core.Cogli1Exporter) -> None

This constructor makes the exporter print each particle as a red sphere of radius 0.5.

  1. __init__(self: baggianalysis.core.Cogli1Exporter, arg0: Callable[[baggianalysis.core.Particle], baggianalysis.core.Cogli1Particle]) -> None

This constructor takes as a parameter a callable that maps each particle into a Cogli1Particle that will be interpreted by the exporter and printed in cogli1 format.

An example of such a callable is the following:

def cogli1_mapper(p):
    c_p = ba.Cogli1Particle()
    if p.position[0] > 0:
        c_p.size = 1.0
        c_p.color = "0,1,0"
    if p.position[1] > 0:
        c_p.show = False

    return c_p

The function defined above will give all those particles that have an x coordinate larger than 0 a size of 1.0 and a green color. Particles with a y coordinate larger than 0 will be hidden. The other particles will be red and have a size of 0.5.

Parameters

mapper (callable) – A callable that takes a particle and returns a Cogli1Particle.

class baggianalysis.core.Cogli1Particle(self: baggianalysis.core.Cogli1Particle)None

Bases: pybind11_builtins.pybind11_object

A utility class used by Cogli1Exporter to customise its output.

By default, the particle is visible, has a size of 0.5 and a red color.

property color

The color of the particle. It can be a name (“red”) or an RGB string (“1,0,0”). Defaults to “red”.

Type

str

property show

If true, the particle will be printed by the exporter. Defaults to True.

Type

bool

property size

The size of the particle. For spheres this corresponds to the radius. Defaults to 0.5.

Type

float

class baggianalysis.core.GenericOxDNAExporter(self: baggianalysis.core.GenericOxDNAExporter, arg0: bool)None

Bases: baggianalysis.core.BaseExporter

Export configurations to the oxDNA file format. The exporter will generate a topology and a configuration file. Note that the filename passed to the write() method is used as-is for the configuration file and as a suffix, prefixed by topology_, for the topology file.

The constructor takes one parameter which tells the exporter whether the topology line should also contain the number of particles of type A.

Parameters

also_print_N_A (bool) – If True, the exporter will print the number of particles of type A in addition to the number of particles in the topology file.

class baggianalysis.core.LAMMPSDataFileExporter(self: baggianalysis.core.LAMMPSDataFileExporter, arg0: str)None

Bases: baggianalysis.core.BaseExporter

Export configurations to the LAMMPS data file format.

The constructor takes one mandatory argument.

Parameters

atom_style (str) – The atom style to be used in printing the data file (see here for details). As of now, only the “atomic” and “bond” styles are supported.