gflownet.envs.crystals.spacegroup
#
Classes to represent crystal environments
Module Contents#
Classes#
Enumeration of the 3 properties of the SpaceGroup Environment: |
|
|
Attributes#
- class gflownet.envs.crystals.spacegroup.Prop[source]#
Bases:
enum.Enum
- Enumeration of the 3 properties of the SpaceGroup Environment:
Crystal lattice system
Point symmetry
Space group
- class gflownet.envs.crystals.spacegroup.SpaceGroup(space_groups_subset=None, n_atoms=None, **kwargs)[source]#
Bases:
gflownet.envs.base.GFlowNetEnv
- Parameters:
space_groups_subset (iterable) β A subset of space group (international) numbers to which to restrict the state space. If None (default), the entire set of 230 space groups is considered.
n_atoms (list of int (optional)) β A list with the number of atoms per element, used to compute constraints on the space group. 0βs are removed from the list. If None, composition/space group constraints are ignored.
- get_action_space()[source]#
Constructs list with all possible actions. An action is described by a tuple (property, index, state_from_type), where property is (0: crystal-lattice system, 1: point symmetry, 2: space group), index is the index of the property set by the action and state_from_type is the state type of the originating state (see self.state_type_indices).
- get_mask_invalid_actions_forward(state=None, done=None)[source]#
- Returns a list of length the action space with values:
True if the forward action is invalid given the current state.
False otherwise.
- Parameters:
state (Optional[List]) β
done (Optional[bool]) β
- Return type:
List
- states2proxy(states)[source]#
Prepares a batch of states in βenvironment formatβ for the proxy: the proxy format is simply the space group.
- Parameters:
states (list or tensor) β A batch of states in environment format, either as a list of states or as a single tensor.
- Returns:
A tensor containing all the states in the batch.
- Return type:
torchtyping.TensorType[batch, state_proxy_dim]
- state2readable(state=None)[source]#
Transforms the state, represented as a list of property indices, into a human-readable string with the format:
<space group idx> | <space group symbol> | <crystal-lattice system> (<crystal-lattice system idx>) | <point symmetry> (<point symmetry idx>) <crystal class> | <point group>
Example
space group: 69 space group symbol: Fmmm crystal-lattice system: orthorhombic (3) point symmetry: centrosymmetric (2) crystal class: rhombic-dipyramidal point group: mmm output:
69 | Fmmm | orthorhombic (3) | centrosymmetric (2) | rhombic-dipyramidal | mmm |
- readable2state(readable)[source]#
Converts a human-readable representation of a state into the standard format. See: state2readable
- get_parents(state=None, done=None, action=None)[source]#
Determines all parents and actions that lead to a state.
- Parameters:
state (list) β
done (bool) β Whether the trajectory is done. If None, done is taken from instance.
action (None) β Ignored
- Returns:
parents (list) β List of parents in state format
actions (list) β List of actions that lead to state for each parent in parents
- step(action)[source]#
Executes step given an action.
- Parameters:
action (tuple) β Action to be executed. See: get_action_space()
- Returns:
self.state (list) β The new state after executing the action
action (tuple) β Action executed
valid (bool) β False, if the action is not allowed for the current state.
- Return type:
Tuple[List[int], Tuple[int, int], bool]
- get_crystal_system(state=None)[source]#
Returns the name of the crystal system given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_lattice_system(state=None)[source]#
Returns the name of the lattice system given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_crystal_lattice_system(state=None)[source]#
Returns the name of the crystal-lattice system given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_point_symmetry(state=None)[source]#
Returns the name of the point symmetry given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_space_group_symbol(state=None)[source]#
Returns the name of the space group symbol given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_space_group(state=None)[source]#
Returns the index of the space group symbol given a state.
- Parameters:
state (List[int]) β
- Return type:
int
- get_crystal_class(state=None)[source]#
Returns the name of the crystal_class given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_point_group(state=None)[source]#
Returns the name of the point group given a state.
- Parameters:
state (List[int]) β
- Return type:
str
- get_state_type(state=None)[source]#
Returns the index of the type of the state passed as an argument. The state type is one of the following (self.state_type_indices):
0: both crystal-lattice system and point symmetry are unset (== 0) 1: crystal-lattice system is set (!= 0); point symmetry is unset 2: crystal-lattice system is unset; point symmetry is set 3: both crystal-lattice system and point symmetry are set
- Parameters:
state (List[int]) β
- Return type:
int
- set_n_atoms_compatibility_dict(n_atoms)[source]#
Sets self.n_atoms_compatibility_dict by calling SpaceGroup.build_n_atoms_compatibility_dict(), which contains a dictionary of {space_group: is_compatible} indicating whether each space_group in space_groups is compatible with the stoichiometry defined by n_atoms.
See: build_n_atoms_compatibility_dict()
- Parameters:
n_atoms (list of int) β A list of number of atoms for each element in a composition. 0s will be removed from the list since they do not count towards the compatibility with a space group.
- static build_n_atoms_compatibility_dict(n_atoms, space_groups)[source]#
Obtains which space groups are compatible with the stoichiometry given as argument (n_atoms).
It relies on a function which, internally, calls pyxtalβs pyxtal.symmetry.Group.check_compatible(). Note that sometimes that pyxtal is known to return invalid results.
- Parameters:
n_atoms (list of int) β A list of number of atoms for each element in a stoichiometry. 0s will be removed from the list since they do not count towards the compatibility with a space group. If None, all space groups will be marked as compatible.
space_groups (list of int) β A list of space group international numbers, in [1, 230]
- Returns:
A dictionary of {space_group (is_compatible} indicating whether each)
space_group in space_groups is compatible with the stoichiometry defined by
n_atoms.