DisNetManager Class¶
Description¶
DisNetManager
is a container class that allows different core implementations of dislocation network data structures to co-exist and interact with each other within the OpenDiS framework. This allows for inter-operability between modules coming from different core libraries (e.g. PyDiS and ExaDiS). Before any core network object, e.g. DisNet
or ExaDisNet
, can be used in modules, they need to be wrapped into a DisNetManager
object, e.g.:
from framework.disnet_manager import DisNetManager
G = ExaDisNet(...)
N = DisNetManager(G)
Then, by specification, each OpenDiS module receives a DisNetManager
object as input, and can convert it to its desired internal data structure via the get_disnet()
method as needed. For instance, an ExaDiS-based module can request an instance of an ExaDisNet
object from the input DisNetManager
object:
class MyExaDisModule():
def Foo(self, N: DisNetManager, state: dict):
G = N.get_disnet(ExaDisNet) # convert network to ExaDisNet object
# perform some operations on the ExaDisNet object
Internally, DisNetManager
performs the conversion between different network object types by invoking the export_data()
/ import_data()
methods implemented in the core network classes. It also retains the type of the active network instance to minimize the number of conversion and memory transfer operations. See section Graph Data Conversion for an example of how to convert between DisNet and ExaDiSNet objects.
Core network classes DisNet
from PyDiS and ExaDisNet
from ExaDiS are the native data structures used to handle dislocation networks in OpenDiS. However, if desired, a user can use or implement its own data structure to interact with dislocation networks in OpenDiS, as long as the new data structure (or wrapper to it) adheres to the DisNet_Base specification class.
Accessing raw data¶
The DisNetManager
provides the export_data()
method that returns the raw network data stored in a dictionary:
data = N.export_data()
where data
is a dictionary containing the following entries:
data["cell"]
: dictionary defining the simulation cell, containing the following entries:data["cell"]["h"]
: simulation cell matrix (columns are the cell vectors)data["cell"]["origin"]
: simulation cell origindata["cell"]["is_periodic"]
: periodic flag along the three dimensions
data["nodes"]
: dictionary containing the nodes attributes within the following entries:data["nodes"]["tags"]
: array of nodes tags (domain,index), size=(Nnodes,2)data["nodes"]["positions"]
: array of nodes positions, size=(Nnodes,3)data["nodes"]["constrains"]
: array of nodes constraints, size=(Nnodes,1)
data["segs"]
: dictionary containing the segments attributes within the following entries:data["segs"]["nodeids"]
: array of indices of segments end-nodes (node1,node2), size=(Nsegs,2)data["segs"]["burgers"]
: array of segments Burgers vectors, size=(Nsegs,3)data["segs"]["planes"]
: array of segments plane normals, size=(Nsegs,3)
Attributes and methods¶
- class DisNetManager
Class for managing multiple implementations of dislocation network. Implements synchronization between different implementations of DisNet.
Attributes
- property G
Get the active network instance.
- property cell
Get the simulation cell object.
Constructor
- __init__(disnet)
Constructs a DisNetManager from an existing dislocation network object.
- Parameters:
disnet – existing dislocation network object
Methods
- get_disnet(disnet_type)
Converts the dislocation network into the requested disnet_type object.
- Return type:
disnet_type network object
- get_active_type()
Returns the type of network object that is currently active.
- Return type:
disnet_type
- import_data(data)
Imports raw network data from a data dictionary. Argument data must be the output of an export_data() method.
- Parameters:
data – Dictionary with keys “cell”, “nodes”, “segs”
- export_data()
Exports the raw network data into a data dictionary.
- Returns:
Dictionary with keys “cell”, “nodes”, “segs”
- write_json(filename)
Writes the DisNetManager data to a JSON file.
- Parameters:
filename – Path to JSON file (str)
- read_json(filename)
Reads the DisNetManager data from a JSON file.
- Parameters:
filename – Path to JSON file (str)
- num_nodes()
Returns the number of nodes in the network.
- Return type:
int
- num_segments()
Returns the number of segments in the network.
- Return type:
int
- is_sane()
Checks if the network is sane.
- Return type:
bool