pyCOFBuilder package

Detailed documentation of the submodules used on pyCOFBuilder.

Submodules

pycofbuilder.building_block module

The BuildingBlock class is used to create the building blocks for the Framework class.

class pycofbuilder.building_block.BuildingBlock(name: str = '', **kwargs)[source]

Bases: object

add_R_group(R_name, R_type)[source]

Adds group R in building blocks

add_connection_group(conector_name)[source]

Adds the functional group by which the COF will be formed from the building blocks

add_connection_group_symm(conector_name)[source]

Adds the functional group by which the COF will be formed from the building blocks

align_to(vec: list = [0, 1, 0], n: int = 0)[source]

Align the first n-th X point to a given vector

Parameters:
  • vec (list) – Vector to align the molecule

  • n (int) – Index of the X point to be aligned

  • align_to_y (bool) – If True, the second point is aligned to the y axis

calculate_size()[source]

Calculate the size of the building block

centralize(by_X=True)[source]

Centralize the molecule on its geometrical center

check_existence(name)[source]
copy()[source]

Return a deep copy of the BuildingBlock object

create_BB_structure(symmetry='L2', core_name='BENZ', conector='CHO', R1='H', R2='H', R3='H', R4='H', R5='H', R6='H', R7='H', R8='H', R9='H')[source]

Create a building block

from_file(path, file_name)[source]

Read a building block from a file

from_name(name)[source]

Automatically read or create a buiding block based on its name

get_Q_points(atom_types, atom_pos)[source]

Get the Q points in a molecule

get_R_points(atom_types, atom_pos)[source]

Get the R points in a molecule

get_X_points()[source]

Get the X points in a molecule

get_available_R()[source]

Get the list of available functional groups

get_available_conector()[source]

Get the list of available conectores

get_available_core()[source]

Get the list of available cores

get_buildingblock_list(shape, connector_group)[source]
n_atoms()[source]

Returns the number of atoms in the unitary cell

print_structure()[source]

Print the structure in xyz format: atom_label pos_x pos_y pos_z

remove_X()[source]
replace_X(target_type)[source]
rotate_around(rotation_axis: list = [1, 0, 0], angle: float = 0.0, degree: bool = True)[source]

Rotate the molecule around a given axis

Parameters:
  • rotation_axis (list) – Rotation axis

  • angle (float) – Rotation angle in degrees

  • degree (bool) – If True, the angle is given in degrees. Default is True.

rotate_to_xy_plane()[source]

Rotate the molecule to the xy plane

save(extension='xyz')[source]
shift(shift_vector: list)[source]

Shift the molecule by a given vector

Parameters:

shift_vector (list) – Shift vector

structure_as_string()[source]

pycofbuilder.cjson module

The CJSON package implements functions to read, create and manipulate Chemical JSON objects.

class pycofbuilder.cjson.ChemJSON[source]

Bases: object

Class to read, create and manupulate ChemJSON files.

file_name

The name of the file.

Type:

str

name

The name of the structure.

Type:

str

cell_parameters

The cell parameters of the structure as a (1,6) list.

Type:

list

cell_matrix

The cell matrix of the structure as a (3,3) list.

Type:

list

cartesian_positions

The cartesian positions of the structure as a (n,3) list.

Type:

list

fractional_positions

The fractional positions of the structure as a (n,3) list.

Type:

list

atomic_numbers

The atomic numbers of the structure as a (n,1) list.

Type:

list

atomic_types

The atomic types of the structure as a (n,1) list.

Type:

list

atomic_labels

The atomic labels of the structure as a (n,1) list.

Type:

list

formula

The formula of the structure.

Type:

str

properties

The properties of the structure.

Type:

dict

partial_charges

A dictionary contaning the partial charges of the atoms on the structure. Example: {‘DDEC’: [0.1, 0.2, 0.15], ‘EQeq’: [0.05, 0.15, 0.19]}

Type:

dict

as_dict()[source]

Returns the structure as a dictionary.

from_cif(path, file_name)[source]

Reads a CIF file from a given path and file_name.

from_cjson(path, file_name)[source]

Reads a ChemJSON file from a given path and file_name.

from_gjf(path, file_name)[source]

Reads a Gaussian input file from a given path and file_name.

from_xyz(path, file_name)[source]

Reads a XYZ file from a given path and file_name.

set_atomic_numbers(atomic_numbers)[source]

Sets the atomic numbers of the structure. The atomic types and formula will be calculated and also updated.

set_atomic_types(atomic_types)[source]

Sets the atomic labels of the structure.

set_cartesian_positions(cartesian_positions)[source]

Sets the cartesian positions of the structure. The fractional positions will be calculated and also updated.

set_cell_matrix(cell_matrix)[source]

Sets the cell matrix of the structure. The cell parameters will be calculated and also updated.

set_cell_parameters(cell_parameters)[source]

Sets the cell parameters of the structure.

set_fractional_positions(fractional_positions)[source]

Sets the fractional positions of the structure. The cartesian positions will be calculated and also updated.

set_properties(properties)[source]

Sets the properties of the structure.

set_results(results)[source]

Sets the results of the structure.

write_cjson(path, file_name)[source]

Writes a ChemJSON file to a given path and file_name.

pycofbuilder.framework module

The Framework class implements definitions and methods for a Framework buiding

class pycofbuilder.framework.Framework(name: str = None, **kwargs)[source]

Bases: object

A class used to represent a Covalent Organic Framework as a reticular entity.

name

Name of the material

Type:

str

out_dir

Path to save the results. If not defined, a out folder will be created in the current directory.

Type:

str

verbosity

Control the printing options. Can be ‘none’, ‘normal’, or ‘debug’. Default: ‘normal’

Type:

str

save_bb

Control the saving of the building blocks. Default: True

Type:

bool

lib_path

Path for saving the building block files. If not defined, a building_blocks folder will be created in the current directory.

Type:

str

topology
Type:

str = None

dimention
Type:

str = None

lattice
Type:

str = None

lattice_sgs
Type:

str = None

space_group
Type:

str = None

space_group_n
Type:

str = None

stacking
Type:

str = None

mass
Type:

str = None

composition
Type:

str = None

charge
Type:

int = 0

multiplicity
Type:

int = 1

chirality
Type:

bool = False

atom_types
Type:

list = []

atom_pos
Type:

list = []

lattice
Type:

list = [[], [], []]

symm_tol
Type:

float = 0.2

angle_tol
Type:

float = 0.2

dist_threshold
Type:

float = 0.8

available_2D_topologies

List of available 2D topologies

Type:

list

available_3D_topologies

List of available 3D topologies

Type:

list

available_topologies

List of all available topologies

Type:

list

available_stacking

List of available stakings for all 2D topologies

Type:

list

lib_bb

String with the name of the folder containing the building block files Default: bb_lib

Type:

str

as_string() str[source]

Returns a string with the Framework information.

check_name_concistency(FrameworkName) tuple[str, str, str, str][source]

Checks if the name is in the correct format and returns a tuple with the building blocks names, the net and the stacking.

In case the name is not in the correct format, an error is raised.

Parameters:

FrameworkName (str, required) – The name of the COF to be created

Returns:

A tuple with the building blocks names, the net and the stacking.

Return type:

tuple[str, str, str, str]

create_bor_structure(BB_D4: str, BB_T3: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with BOR network.

The DIA net is composed of one tetrapodal tetrahedical building block and one tripodal triangular building block.

Parameters:
  • BB_D4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal triangular Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_dia_a_structure(BB_D4: str, BB_L2: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with DIA-A network.

The DIA net is composed of two tetrapodal tetrahedical building blocks.

Parameters:
  • BB_D4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the dipodal linear Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_dia_structure(BB_D41: str, BB_D42: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with DIA network.

The DIA net is composed of two tetrapodal tetrahedical building blocks.

Parameters:
  • BB_D41 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_D42 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_fxt_a_structure(BB_S4: str, BB_L2: str, stacking: str = 'AA', c_parameter_base: float = 3.6, print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with FXT-A network.

The FXT-A net is composed of one tetrapodal and one linear building blocks.

Parameters:
  • BB_S4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the bipodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_fxt_structure(BB_S4_A: str, BB_S4_B: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with FXT network.

The FXT net is composed of two tetrapodal building blocks.

Parameters:
  • BB_S4_A (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_S4_B (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hcb_a_structure(BB_T3: str, BB_L2: str, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HCB-A network.

The HCB-A net is composed of one tripodal and one linear building blocks.

Parameters:
  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the linear Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • c_parameter_base (float, optional) – The base value for interlayer distance in angstroms (default is 3.6)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name

  2. lattice type

  3. hall symbol of the cristaline structure

  4. space group

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hcb_structure(BB_T3_A, BB_T3_B, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HCB network.

The HCB net is composed of two tripodal building blocks.

Parameters:
  • BB_T3_1 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block A

  • BB_T3_2 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hxl_a_structure(BB_H6: str, BB_L2: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HXL-A network.

The HXL-A net is composed of one hexapodal and one linear building blocks.

Parameters:
  • BB_H6 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_kgd_structure(BB_H6: str, BB_T3: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with KGD network.

The KGD net is composed of one hexapodal and one tripodal building blocks.

Parameters:
  • BB_H6 (BuildingBlock, required) – The BuildingBlock object of the hexapodal Buiding Block

  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • c_parameter_base (float, optional) – The base value for interlayer distance in angstroms (default is 3.6)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_sql_a_structure(BB_S4: str, BB_L2: str, stacking: str = 'AA', c_parameter_base: float = 3.6, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with SQL-A network.

The SQL-A net is composed of one tetrapodal and one linear building blocks.

Parameters:
  • BB_S4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the bipodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_sql_structure(BB_S4_A: str, BB_S4_B: str, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with SQL network.

The SQL net is composed of two tetrapodal building blocks.

Parameters:
  • BB_S4_A (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_S4_B (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

from_building_blocks(bb1: BuildingBlock, bb2: BuildingBlock, net: str, stacking: str, **kwargs)[source]

Creates a COF from the building blocks.

Parameters:
  • BB1 (BuildingBlock, required) – The first building block

  • BB2 (BuildingBlock, required) – The second building block

  • Net (str, required) – The network of the COF

  • Stacking (str, required) – The stacking of the COF

Returns:

COF – The COF object

Return type:

Framework

from_name(FrameworkName, **kwargs) None[source]

Creates a COF from a given FrameworkName.

Parameters:

FrameworkName (str, required) – The name of the COF to be created

Returns:

COF – The COF object

Return type:

Framework

get_available_topologies(dimensionality: str = 'all', print_result: bool = True)[source]

Get the available topologies implemented in the class.

Parameters:
  • dimensionality (str, optional) – The dimensionality of the topologies to be printed. Can be ‘all’, ‘2D’ or ‘3D’. Default: ‘all’

  • print_result (bool, optional) – If True, the available topologies are printed.

Returns:

dimensionality_list – A list with the available topologies.

Return type:

list

get_n_atoms() int[source]

Returns the number of atoms in the unitary cell

save(fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, primitive=False, save_bonds=True) None[source]

Save the structure in a specif file format.

Parameters:
  • fmt (str, optional) – The file format to be saved Can be json, cif, xyz, turbomole, vasp, xsf, pdb, pqr, qe. Default: ‘cif’

  • supercell (list, optional) – The supercell to be used to save the structure. Default: [1,1,1]

  • save_dir (str, optional) – The path to save the structure. By default, the structure is saved in a out folder created in the current directory.

  • primitive (bool, optional) – If True, the primitive cell is saved. Otherwise, the conventional cell is saved. Default: False

pycofbuilder.io_tools module

This module contains tools for input and output file manipulation used by pyCOFBuilder.

pycofbuilder.io_tools.convert_cif_2_qe(out_path, file_name)[source]

Convert a cif file to a Quantum Espresso input file

Parameters:
  • out_path (str) – Path to the file.

  • file_name (str) – Name of the file. Does not neet to contain the .cif extention.

pycofbuilder.io_tools.convert_cif_2_xyz(path, file_name, supercell=[1, 1, 1])[source]
pycofbuilder.io_tools.convert_gjf_2_xyz(path, file_name)[source]
pycofbuilder.io_tools.convert_json_2_cif(origin_path, file_name, destiny_path, charge_type='None')[source]

Convert a file in format .json to .cif.

Parameters:
  • origin_path (str) – Path to the ‘.json’ file.

  • file_name (str) – Name of the file. Does not neet to contain the .json extention.

  • destiny_path (str) – path where the .cif file will be saved.

pycofbuilder.io_tools.convert_xyz_2_gjf(path, file_name)[source]
pycofbuilder.io_tools.create_COF_json(name) dict[source]

Create a empty dictionary with the COF information.

pycofbuilder.io_tools.create_empty_CJSON() dict[source]

Create a dictionary with the structure information to be saved using the chemical JSON format.

pycofbuilder.io_tools.create_structure_CJSON(StructureName: str, CellParameters: list = None, CellMatrix: list = None, AtomTypes: list = None, AtomLabels: list = [], AtomPositions: list = None, CartesianPositions: bool = False, BondIndexes: list = [], BondOrders: list = [], PartialCharges: dict = {}) dict[source]

Creates a dictionary with the structure information to be saved using the chemical JSON format.

Parameters:
  • StructureName (str) – Name of the structure.

  • CellParameters (list) – List with the cell parameters.

  • CellMatrix (list) – List with the cell matrix. Optional

  • AtomTypes (list) – List with the atom types.

  • AtomLabels (list) – List with the atom labels.

  • AtomPositions (list) – List with the atom positions.

  • CartesianPositions (bool) – If True, the coordinates are in cartesian coordinates.

  • BondIndexes (list) – List with the bonds indexes and bond length.

  • BondOrders (list) – List with the bond orders.

  • PartialCharges (dict) – Dictionary with the partial charges.

pycofbuilder.io_tools.generate_mol_dict(path, file_name, name, code, smiles)[source]
pycofbuilder.io_tools.read_cif(path, file_name)[source]

Reads a file in format .cif from the path given and returns a list containg the N atom labels and a Nx3 array contaning the atoms coordinates.

Parameters:
  • path (str) – Path to the file.

  • file_name (str) – Name of the cif file. Does not neet to contain the .cif extention.

Returns:

  • cell (numpy array) – 3x3 array contaning the cell vectors.

  • atom_labels (list) – List of strings containing containg the N atom labels.

  • atom_pos (numpy array) – Nx3 array contaning the atoms coordinates

  • charges (list) – List of strings containing containg the N atom partial charges.

pycofbuilder.io_tools.read_gjf(path, file_name)[source]

Reads a file in format .gjf from the path given and returns a list containg the N atom labels and a Nx3 array contaning the atoms coordinates.

Parameters:
  • path (str) – Path to the file.

  • file_name (str) – Name of the gjf file. Does not neet to contain the .gjf extention.

Returns:

  • atom_labels (list) – List of strings containing containg the N atom labels.

  • atom_pos (numpy array) – Nx3 array contaning the atoms coordinates

pycofbuilder.io_tools.read_json(path, name)[source]
pycofbuilder.io_tools.read_pdb(path, file_name)[source]

Reads a file in format .pdb from the path given and returns a list containg the N atom labels and a Nx3 array contaning the atoms coordinates.

Parameters:
  • path (str) – Path to the file.

  • file_name (str) – Name of the pdb file. Does not neet to contain the .pdb extention.

Returns:

  • atom_labels (list) – List of strings containing containg the N atom labels.

  • atom_pos (numpy array) – Nx3 array contaning the atoms coordinates

pycofbuilder.io_tools.read_xyz(path, file_name)[source]

Reads a file in format .xyz from the path given and returns a list containg the N atom labels and a Nx3 array contaning the atoms coordinates.

Parameters:
  • path (str) – Path to the file.

  • file_name (str) – Name of the xyz file. Does not neet to contain the .xyz extention.

Returns:

  • atom_labels (list) – List of strings containing containg the N atom labels.

  • atom_pos (numpy array) – Nx3 array contaning the atoms coordinates

pycofbuilder.io_tools.save_chemjson(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, frac_coords=False)[source]

Save a file in format .json on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_cif(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, frac_coords=False)[source]

Save a file in format .cif on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_csv(path, file_name, data, delimiter=',', head=False)[source]

Saves a file in format .csv.

Parameters:
  • path (str) – Path to the file.

  • file_name (str) – Name of the csv file. Does not neet to contain the .csv extention.

  • data (list) – Data to be saved.

  • delimiter (str) – Delimiter of the columns. , is the default.

  • head (str) – Names of the columns.

pycofbuilder.io_tools.save_gjf(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False, header: str = 'opt pm6')[source]

Save a file in format .pqr on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

  • header (str) – Parameters for Gaussian calculations.

pycofbuilder.io_tools.save_pdb(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save a file in format .pdb on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_pqr(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save a file in format .pqr on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_qe(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False, calc_type: str = 'scf', kspacing: float = 0.3)[source]

Save the structure in Quantum Espresso .pwscf format.

The input_dict can be used to specify the input parameters for the QuantumESPRESSO calculation.

This dictionary must contain the keys: control, system, electrons, and ions. Each of these keys must contain a dictionary with the corresponding input parameters. This dictionary can contain the kpoints item, with the kpoints grid as a list of 3 integers. Additionally, it can contain the kspacing item, with the kpoints spacing as a float. In this case the kpoints grid will be calculated automatically. By default, the kspacing is set to 0.3.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

  • calc_type (str) – Type of calculation. Can be ‘scf’, ‘vc-relax’, ‘relax’, ‘md’, ‘vc-md’, ‘vc-tddft’, ‘tddft’.

  • kspacing (float) – Kpoints spacing in 1/Angstrom.

pycofbuilder.io_tools.save_turbomole(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save the structure in Turbomole .coord format on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_vasp(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save the structure in VASP .vasp format on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_xsf(path: str, file_name: str, cell: list, atom_types: list, atom_labels: list, atom_pos: list, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save a file in format .xsf on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.save_xyz(path: str, file_name: str, atom_types: list, atom_pos: list, atom_labels: list = None, cell: list = None, atom_charges: list = None, bonds: list = None, bond_orders: list = None, frac_coords=False)[source]

Save a file in format .xyz on the path.

Parameters:
  • path (str) – Path to the save the file.

  • file_name (str) – Name of the file. Does not neet to contain the extention.

  • cell (numpy array) – Can be a 3x3 array contaning the cell vectors or a list with the 6 cell parameters.

  • atom_types (list) – List of strings containing containg the N atom types

  • atom_label (list) – List of strings containing containg the N atom labels

  • atom_pos (list) – Nx3 array contaning the atoms coordinates.

  • atom_charges (list) – List of strings containing containg the N atom partial charges.

  • bonds (list) – List of lists containing the index of the bonded atoms and the bond length.

  • frac_coords (bool) – If True, the coordinates are in fractional coordinates.

pycofbuilder.io_tools.write_json(path, name, COF_json)[source]

pycofbuilder.tools module

This module contains the tools used by pyCOFBuilder.

pycofbuilder.tools.angle(v1, v2, unit='degree')[source]

Calculates the angle between two vectors v1 and v2.

Parameters:
  • v1 (array) – (N,1) matrix with N dimensions

  • v2 (array) – (N,1) matrix with N dimensions

  • unit (str) – Unit of the output. Could be ‘degree’, ‘radians’ or ‘cos’.

Returns:

angle – Angle in the selected unit.

Return type:

float

pycofbuilder.tools.calculate_UnitCells(cell, cutoff)[source]

Calculate the number of unit cell repetitions so that all supercell lengths are larger than twice the interaction potential cut-off radius.

RASPA considers the perpendicular directions the directions perpendicular to the ab, bc, and ca planes. Thus, the directions depend on who the crystallographic vectors a, b, and c are and the length in the perpendicular directions would be the projections of the crystallographic vectors on the vectors a x b, b x c, and c x a. (here x means cross product)

Parameters:

cell_matrix (array) – (3,3) cell vectors or (6,1)

Returns:

(3,1) list containg the number of repiting units in x, y, z directions.

Return type:

superCell

pycofbuilder.tools.cell_to_cellpar(cell, radians=False)[source]

Returns the cell parameters [a, b, c, alpha, beta, gamma] given a 3x3 cell matrix.

Angles are in degrees unless radian=True is used.

Parameters:
  • cell (array) – (3,3) matrix of cell vectors v1, v2, and v3

  • radians (bool) – Return the cell angles in radians

Returns:

cellpar – (6,1) vector with the cell parameters

Return type:

array

pycofbuilder.tools.cell_to_ibrav(cell)[source]

Return the ibrav number for a given cell.

pycofbuilder.tools.cellpar_to_cell(cellpar, ab_normal=(0, 0, 1), a_direction=None)[source]

Return a 3x3 cell matrix from cell parameters (a,b,c,alpha,beta, and gamma).

Angles must be in degrees.

The returned cell is orientated such that a and b are normal to ab_normal and a is parallel to the projection of a_direction in the a-b plane.

Default a_direction is (1,0,0), unless this is parallel to ab_normal, in which case default a_direction is (0,0,1).

The returned cell has the vectors va, vb and vc along the rows. The cell will be oriented such that va and vb are normal to ab_normal and va will be along the projection of a_direction onto the a-b plane.

Parameters:
  • cellpar (array) – (6,1) vector with the cell parameters

  • ab_normal (array) – Normal vector between a and b cell vectors. Default: (0, 0, 1)

  • a_direction (array) – Specific direction for the a vector. Default: None

Returns:

cell – (3,3) matrix of cell vectors v1, v2, and v3

Return type:

array

pycofbuilder.tools.cellpar_to_lammpsbox(a: float, b: float, c: float, alpha: float, beta: float, gamma: float, angle_in_degrees: bool = True)[source]

Return the box parameters lx, ly, lz, xy, xz, yz for LAMMPS data input. :param a: The lengths of the edges. :type a: float :param b: The lengths of the edges. :type b: float :param c: The lengths of the edges. :type c: float :param alpha: The angles between the sides. :type alpha: float :param gamma: The angles between the sides. :type gamma: float :param beta: The angles between the sides. :type beta: float :param angle_in_degrees: True if alpha, beta and gamma are expressed in degrees. :type angle_in_degrees: bool

Returns:

r – The 1x6 array with the box parameters ‘lx’, ‘ly’, ‘lz’, ‘xy’, ‘xz’, ‘yz’.

Return type:

array_like

pycofbuilder.tools.change_X_atoms(atom_labels, atom_pos, bond_atom) tuple[source]

Changes the X atom for the desired bond_atom or remove it if bond_atom == ‘R’.

Parameters:
  • atom_labels (list) – List containing the atom labels

  • atom_pos (list) – List containing the atom position

Returns:

  • labels (list) – List containing the processed atom labels

  • pos (list) – List containing the processed atom position

pycofbuilder.tools.classify_unit_cell(cell, thr=0.001) str[source]

Determine the bravais lattice based on the cell lattice. The cell lattice can be the cell parameters as (6,1) array or the cell vectors as (3x3) array.

Bravais lattice can be cubic, tetragonal, orthorhombic, hexagonal, monoclinic, or triclinic.

Parameters:
  • cell (array) – Array with the cell vectors or parameters

  • threshold (float) – Numeric threshold for the analysis. Default: 1e-3

Returns:

cell_type – Bravais lattice.

Return type:

string

pycofbuilder.tools.closest_atom(label_1: str, pos_1: list, labels: list, pos: list)[source]

Find the closest atom to a given atom

Parameters:
  • label_1 (string) – String containing the label of the atom

  • pos_1 (list) – Array containing the position of the atom

  • labels (list) – List containing the all the atom labels on the structure

  • pos (list) – List containing the all the atom positions on the structure

Returns:

  • closest_label (string) – String containing the label of the closest atom

  • closest_position (array) – Array containing the position of the closest atom

  • euclidian_distance (float) – Euclidian distance between the two atoms

pycofbuilder.tools.closest_atom_struc(label_1, pos_1, labels, pos)[source]

Finds the closest atom on the structure to a given atom

pycofbuilder.tools.create_CellBox(A, B, C, alpha, beta, gamma)[source]

Creates the CellBox using the same expression as RASPA.

pycofbuilder.tools.elements_dict(property='atomic_mass')[source]

Returns a dictionary containing the elements symbol and its selected property.

Parameters:

prop (string) –

The desired property can be:
  • ”full_name”

  • ”atomic_number”

  • ”atomic_mass”

  • ”polarizability”

  • ”pauling_electronegativity”

  • ”thermo_electronegativity”

  • ”mulliken_electronegativity”

  • ”sanderson_electronegativity”

  • ”allen_electronegativity”

  • ”ghosh_electronegativity”

  • ”martynov_batsanov_electronegativity”

  • ”atomic_radius”

  • ”covalent_radius”

  • ”vdw_radius”

Returns:

prop_dic – A dictionary containing the elements symbol and its respective property.

Return type:

dictionary

pycofbuilder.tools.equal_value(val1, val2, threshold=0.001) bool[source]

Determine if two values are equal based on a given threshold.

pycofbuilder.tools.find_index(element, e_list)[source]

Finds the index of a given element in a list

Parameters:
  • element (string) – String containing the label of the element in e_list

  • e_list (list) – List with the atom labels

Returns:

i – The index of element in the e_list

Return type:

int

pycofbuilder.tools.formula_from_atom_list(AtomLabels: list) str[source]

Create a string with the formula of the structure from the list of atoms.

Parameters:

AtomLabels (list) – List of strings containing the atom labels.

Returns:

formula – String with the formula of the structure.

Return type:

str

pycofbuilder.tools.get_bond_atom(connector_1: str, connector_2: str) str[source]

Get the atom that will be used to bond two building blocks.

pycofbuilder.tools.get_bonds(structure, cutoff=1.3)[source]

Get the bonded atoms in a structure based on the distance between them.

Parameters:
  • structure (pymatgen.Structure) – Structure object of pymatgen

  • cutoff (float) – Cutoff factor for the covalent radii. Default: 1.3 Å

pycofbuilder.tools.get_cartesian_to_fractional_matrix(a: float, b: float, c: float, alpha: float, beta: float, gamma: float, angle_in_degrees: bool = True) -> array(<class 'float'>, dtype=object)[source]

Return the transformation matrix that converts cartesian coordinates to fractional coordinates.

Parameters:
  • a (float) – The lengths of the edges.

  • b (float) – The lengths of the edges.

  • c (float) – The lengths of the edges.

  • alpha (float) – The angles between the sides.

  • gamma (float) – The angles between the sides.

  • beta (float) – The angles between the sides.

  • angle_in_degrees (bool) – True if alpha, beta and gamma are expressed in degrees.

Returns:

T_matrix – The 3x3 rotation matrix. R_frac = np.dot(T_matrix, R_cart).

Return type:

np.array

pycofbuilder.tools.get_fractional_to_cartesian_matrix(cell_a: float, cell_b: float, cell_c: float, alpha: float, beta: float, gamma: float, angle_in_degrees: bool = True) -> array(<class 'float'>, dtype=object)[source]

Return the transformation matrix that converts fractional coordinates to cartesian coordinates.

Parameters:
  • a (float) – The lengths of the edges.

  • b (float) – The lengths of the edges.

  • c (float) – The lengths of the edges.

  • alpha (float) – The angles between the sides.

  • gamma (float) – The angles between the sides.

  • beta (float) – The angles between the sides.

  • angle_in_degrees (bool) – True if alpha, beta and gamma are expressed in degrees.

Returns:

T_matrix – The 3x3 rotation matrix. V_cart = np.dot(T_matrix, V_frac).

Return type:

ndarray

pycofbuilder.tools.get_framework_symm_text(name, lattice, hall, space_group, space_number, symm_op)[source]

Get the text for the framework symmop

pycofbuilder.tools.get_kgrid(cell, distance=0.3) tuple[source]

Get the k-points grid in the reciprocal space with a given distance for a cell given in cell parameters of cell vectors.

Parameters:
  • cell (array) – (3,1) array for cell vectors or (6,1) array for cell parameters

  • distance (float) – distance between the points in the reciprocal space

Returns:

  • kx (int) – Number of points in the x direction on reciprocal space

  • ky (int) – Number of points in the y direction on reciprocal space

  • kz (int) – Number of points in the z direction on reciprocal space

pycofbuilder.tools.get_reciprocal_vectors(cell) tuple[source]

Get the reciprocal vectors of a cell given in cell parameters of cell vectors.

Parameters:

cell (array) – (3,1) array for cell vectors or (6,1) array for cell parameters

Returns:

  • b1 (array) – (3,1) array containing b_1 vector in the reciprocal space

  • b2 (array) – (3,1) array containing b_2 vector in the reciprocal space

  • b3 (array) – (3,1) array containing b_3 vector in the reciprocal space

pycofbuilder.tools.ibrav_to_cell(ibrav, celldm1, celldm2, celldm3, celldm4, celldm5, celldm6)[source]

Convert a value of ibrav to a cell.

Parameters:
  • ibrav (int) –

  • celldmx (float) –

Returns:

cell – The cell as a 3x3 numpy array

Return type:

matrix

pycofbuilder.tools.is_bonded(atom1: str, atom2: str, dist: float, cutoff: float = 1.3)[source]

Determine if two atoms are bonded based on the distance between them. Two atoms are considered bonded if the distance between them is less than the sum of their covalent radii multiplied by a cutoff factor.

Parameters:
  • atom1 (str) – Label of the first atom

  • atom2 (str) – Label of the second atom

  • dist (float) – Distance between the two atoms

  • cutoff (float) – Cutoff factor for the covalent radii. Default: 1.3

pycofbuilder.tools.print_command(text, verbose, match)[source]
pycofbuilder.tools.print_framework_name(name, lattice, hall, space_group, space_number, symm_op)[source]

Print the results of the created structure

pycofbuilder.tools.rmsd(V, W)[source]

Calculate Root-mean-square deviation from two sets of vectors V and W. :param V: (N,D) matrix, where N is points and D is dimension. :type V: array :param W: (N,D) matrix, where N is points and D is dimension. :type W: array

Returns:

rmsd – Root-mean-square deviation between the two vectors

Return type:

float

pycofbuilder.tools.rotation_matrix_from_vectors(vec1, vec2)[source]

Find the rotation matrix that aligns vec1 to vec2

Parameters:
  • vec1 (array) – (3,3) array

  • vec2 (array) – (3,3) array

Returns:

rotation_matrix – A transform matrix (3x3) which when applied to vec1, aligns it with vec2.

Return type:

array

pycofbuilder.tools.smiles_to_xsmiles(smiles_string: str) str[source]

Converts a SMILES string to an extended SMILES string with labels

Parameters:

smiles_string (str) – SMILES string to be converted

Returns:

  • xsmiles (str) – Extended SMILES string with special labels

  • xsmiles_label (str) – xsmiles labels for images with the special labels

  • composition (str) – String containing the composition

pycofbuilder.tools.unit_vector(vector)[source]

Return a unit vector in the same direction as x.

Module contents

class pycofbuilder.BuildingBlock(name: str = '', **kwargs)[source]

Bases: object

add_R_group(R_name, R_type)[source]

Adds group R in building blocks

add_connection_group(conector_name)[source]

Adds the functional group by which the COF will be formed from the building blocks

add_connection_group_symm(conector_name)[source]

Adds the functional group by which the COF will be formed from the building blocks

align_to(vec: list = [0, 1, 0], n: int = 0)[source]

Align the first n-th X point to a given vector

Parameters:
  • vec (list) – Vector to align the molecule

  • n (int) – Index of the X point to be aligned

  • align_to_y (bool) – If True, the second point is aligned to the y axis

calculate_size()[source]

Calculate the size of the building block

centralize(by_X=True)[source]

Centralize the molecule on its geometrical center

check_existence(name)[source]
copy()[source]

Return a deep copy of the BuildingBlock object

create_BB_structure(symmetry='L2', core_name='BENZ', conector='CHO', R1='H', R2='H', R3='H', R4='H', R5='H', R6='H', R7='H', R8='H', R9='H')[source]

Create a building block

from_file(path, file_name)[source]

Read a building block from a file

from_name(name)[source]

Automatically read or create a buiding block based on its name

get_Q_points(atom_types, atom_pos)[source]

Get the Q points in a molecule

get_R_points(atom_types, atom_pos)[source]

Get the R points in a molecule

get_X_points()[source]

Get the X points in a molecule

get_available_R()[source]

Get the list of available functional groups

get_available_conector()[source]

Get the list of available conectores

get_available_core()[source]

Get the list of available cores

get_buildingblock_list(shape, connector_group)[source]
n_atoms()[source]

Returns the number of atoms in the unitary cell

print_structure()[source]

Print the structure in xyz format: atom_label pos_x pos_y pos_z

remove_X()[source]
replace_X(target_type)[source]
rotate_around(rotation_axis: list = [1, 0, 0], angle: float = 0.0, degree: bool = True)[source]

Rotate the molecule around a given axis

Parameters:
  • rotation_axis (list) – Rotation axis

  • angle (float) – Rotation angle in degrees

  • degree (bool) – If True, the angle is given in degrees. Default is True.

rotate_to_xy_plane()[source]

Rotate the molecule to the xy plane

save(extension='xyz')[source]
shift(shift_vector: list)[source]

Shift the molecule by a given vector

Parameters:

shift_vector (list) – Shift vector

structure_as_string()[source]
class pycofbuilder.Framework(name: str = None, **kwargs)[source]

Bases: object

A class used to represent a Covalent Organic Framework as a reticular entity.

name

Name of the material

Type:

str

out_dir

Path to save the results. If not defined, a out folder will be created in the current directory.

Type:

str

verbosity

Control the printing options. Can be ‘none’, ‘normal’, or ‘debug’. Default: ‘normal’

Type:

str

save_bb

Control the saving of the building blocks. Default: True

Type:

bool

lib_path

Path for saving the building block files. If not defined, a building_blocks folder will be created in the current directory.

Type:

str

topology
Type:

str = None

dimention
Type:

str = None

lattice
Type:

str = None

lattice_sgs
Type:

str = None

space_group
Type:

str = None

space_group_n
Type:

str = None

stacking
Type:

str = None

mass
Type:

str = None

composition
Type:

str = None

charge
Type:

int = 0

multiplicity
Type:

int = 1

chirality
Type:

bool = False

atom_types
Type:

list = []

atom_pos
Type:

list = []

lattice
Type:

list = [[], [], []]

symm_tol
Type:

float = 0.2

angle_tol
Type:

float = 0.2

dist_threshold
Type:

float = 0.8

available_2D_topologies

List of available 2D topologies

Type:

list

available_3D_topologies

List of available 3D topologies

Type:

list

available_topologies

List of all available topologies

Type:

list

available_stacking

List of available stakings for all 2D topologies

Type:

list

lib_bb

String with the name of the folder containing the building block files Default: bb_lib

Type:

str

as_string() str[source]

Returns a string with the Framework information.

check_name_concistency(FrameworkName) tuple[str, str, str, str][source]

Checks if the name is in the correct format and returns a tuple with the building blocks names, the net and the stacking.

In case the name is not in the correct format, an error is raised.

Parameters:

FrameworkName (str, required) – The name of the COF to be created

Returns:

A tuple with the building blocks names, the net and the stacking.

Return type:

tuple[str, str, str, str]

create_bor_structure(BB_D4: str, BB_T3: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with BOR network.

The DIA net is composed of one tetrapodal tetrahedical building block and one tripodal triangular building block.

Parameters:
  • BB_D4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal triangular Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_dia_a_structure(BB_D4: str, BB_L2: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with DIA-A network.

The DIA net is composed of two tetrapodal tetrahedical building blocks.

Parameters:
  • BB_D4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the dipodal linear Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_dia_structure(BB_D41: str, BB_D42: str, interp_dg: str = '1', d_param_base: float = 7.2, print_result: bool = True, **kwargs)[source]

Creates a COF with DIA network.

The DIA net is composed of two tetrapodal tetrahedical building blocks.

Parameters:
  • BB_D41 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • BB_D42 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal tetrahedical Buiding Block

  • interp_dg (str, optional) – The degree of interpenetration of the framework (default is ‘1’)

  • d_param_base (float, optional) – The base value for interlayer distance in angstroms (default is 7.2)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_fxt_a_structure(BB_S4: str, BB_L2: str, stacking: str = 'AA', c_parameter_base: float = 3.6, print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with FXT-A network.

The FXT-A net is composed of one tetrapodal and one linear building blocks.

Parameters:
  • BB_S4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the bipodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_fxt_structure(BB_S4_A: str, BB_S4_B: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with FXT network.

The FXT net is composed of two tetrapodal building blocks.

Parameters:
  • BB_S4_A (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_S4_B (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hcb_a_structure(BB_T3: str, BB_L2: str, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HCB-A network.

The HCB-A net is composed of one tripodal and one linear building blocks.

Parameters:
  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the linear Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • c_parameter_base (float, optional) – The base value for interlayer distance in angstroms (default is 3.6)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name

  2. lattice type

  3. hall symbol of the cristaline structure

  4. space group

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hcb_structure(BB_T3_A, BB_T3_B, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HCB network.

The HCB net is composed of two tripodal building blocks.

Parameters:
  • BB_T3_1 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block A

  • BB_T3_2 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_hxl_a_structure(BB_H6: str, BB_L2: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with HXL-A network.

The HXL-A net is composed of one hexapodal and one linear building blocks.

Parameters:
  • BB_H6 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_kgd_structure(BB_H6: str, BB_T3: str, stacking: str = 'AA', print_result: bool = True, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with KGD network.

The KGD net is composed of one hexapodal and one tripodal building blocks.

Parameters:
  • BB_H6 (BuildingBlock, required) – The BuildingBlock object of the hexapodal Buiding Block

  • BB_T3 (BuildingBlock, required) – The BuildingBlock object of the tripodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • c_parameter_base (float, optional) – The base value for interlayer distance in angstroms (default is 3.6)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_sql_a_structure(BB_S4: str, BB_L2: str, stacking: str = 'AA', c_parameter_base: float = 3.6, slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with SQL-A network.

The SQL-A net is composed of one tetrapodal and one linear building blocks.

Parameters:
  • BB_S4 (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block

  • BB_L2 (BuildingBlock, required) – The BuildingBlock object of the bipodal Buiding Block

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

create_sql_structure(BB_S4_A: str, BB_S4_B: str, stacking: str = 'AA', slab: float = 10.0, shift_vector: list = [1.0, 1.0, 0], tilt_angle: float = 5.0)[source]

Creates a COF with SQL network.

The SQL net is composed of two tetrapodal building blocks.

Parameters:
  • BB_S4_A (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block A

  • BB_S4_B (BuildingBlock, required) – The BuildingBlock object of the tetrapodal Buiding Block B

  • stacking (str, optional) – The stacking pattern of the COF layers (default is ‘AA’)

  • print_result (bool, optional) – Parameter for the control for printing the result (default is True)

  • slab (float, optional) – Default parameter for the interlayer slab (default is 10.0)

  • shift_vector (list, optional) – Shift vector for the AAl and AAt stakings (defatult is [1.0,1.0,0])

  • tilt_angle (float, optional) – Tilt angle for the AAt staking in degrees (default is 5.0)

Returns:

A list of strings containing:
  1. the structure name,

  2. lattice type,

  3. hall symbol of the cristaline structure,

  4. space group,

  5. number of the space group,

  6. number of operation symmetry

Return type:

list

from_building_blocks(bb1: BuildingBlock, bb2: BuildingBlock, net: str, stacking: str, **kwargs)[source]

Creates a COF from the building blocks.

Parameters:
  • BB1 (BuildingBlock, required) – The first building block

  • BB2 (BuildingBlock, required) – The second building block

  • Net (str, required) – The network of the COF

  • Stacking (str, required) – The stacking of the COF

Returns:

COF – The COF object

Return type:

Framework

from_name(FrameworkName, **kwargs) None[source]

Creates a COF from a given FrameworkName.

Parameters:

FrameworkName (str, required) – The name of the COF to be created

Returns:

COF – The COF object

Return type:

Framework

get_available_topologies(dimensionality: str = 'all', print_result: bool = True)[source]

Get the available topologies implemented in the class.

Parameters:
  • dimensionality (str, optional) – The dimensionality of the topologies to be printed. Can be ‘all’, ‘2D’ or ‘3D’. Default: ‘all’

  • print_result (bool, optional) – If True, the available topologies are printed.

Returns:

dimensionality_list – A list with the available topologies.

Return type:

list

get_n_atoms() int[source]

Returns the number of atoms in the unitary cell

save(fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, primitive=False, save_bonds=True) None[source]

Save the structure in a specif file format.

Parameters:
  • fmt (str, optional) – The file format to be saved Can be json, cif, xyz, turbomole, vasp, xsf, pdb, pqr, qe. Default: ‘cif’

  • supercell (list, optional) – The supercell to be used to save the structure. Default: [1,1,1]

  • save_dir (str, optional) – The path to save the structure. By default, the structure is saved in a out folder created in the current directory.

  • primitive (bool, optional) – If True, the primitive cell is saved. Otherwise, the conventional cell is saved. Default: False