### QuantumESPRESSO Input (Bash) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/file_formats/qe.rst.txt Example QuantumESPRESSO input file configuration using bash. It sets up a self-consistent field calculation with specific parameters for the system and electrons. ```bash &CONTROL calculation = 'scf' restart_mode = 'from_scratch' pseudo_dir = '/path/to/pseudopotentials/' outdir = './tmp' prefix = 'molecule' disk_io = 'low' verbosity = 'high' / &SYSTEM ibrav = 1 celldm(1) = 10.0 nat = 3 ntyp = 2 ecutwfc = 30.0 occupations = 'smearing' smearing = 'mv' degauss = 0.02 / &ELECTRONS conv_thr = 1.0e-8 mixing_beta = 0.7 / ATOMIC_SPECIES O 16.00 O.pbe-mt_fhi.UPF H 1.008 H.pbe-mt_fhi.UPF ATOMIC_POSITIONS crystal O 0.0000 0.0000 0.0000 H 0.7570 0.5860 0.0000 H -0.7570 0.5860 0.0000 K_POINTS automatic 4 4 4 0 0 0 ``` -------------------------------- ### QuantumESPRESSO pwscf Input File Example Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/file_formats/qe.rst A basic QuantumESPRESSO input file for a self-consistent field (SCF) calculation. It defines the calculation type, system parameters (crystal structure, atomic species, positions), electronic properties, and k-point sampling. This example is for a simple molecule and requires appropriate pseudopotential files. ```bash &CONTROL calculation = 'scf' restart_mode = 'from_scratch' pseudo_dir = '/path/to/pseudopotentials/' outdir = './tmp' prefix = 'molecule' disk_io = 'low' verbosity = 'high' / &SYSTEM ibrav = 1 celldm(1) = 10.0 nat = 3 ntyp = 2 ecutwfc = 30.0 occupations = 'smearing' smearing = 'mv' degauss = 0.02 / &ELECTRONS conv_thr = 1.0e-8 mixing_beta = 0.7 / ATOMIC_SPECIES O 16.00 O.pbe-mt_fhi.UPF H 1.008 H.pbe-mt_fhi.UPF ATOMIC_POSITIONS crystal O 0.0000 0.0000 0.0000 H 0.7570 0.5860 0.0000 H -0.7570 0.5860 0.0000 K_POINTS automatic 4 4 4 0 0 0 ``` -------------------------------- ### Install PyCofbuilder and Dependencies with Pip Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/pyCOFBuilder_example.ipynb This command installs the pycofbuilder package along with several scientific computing libraries such as simplejson, pymatgen, gemmi, ase, and others. It utilizes pip, the standard package installer for Python. Ensure you have pip installed and a stable internet connection. ```bash # install the pycofbuilder package using pip ! pip install simplejson pymatgen gemmi ase pycofbuilder ``` -------------------------------- ### Turbomole Coordinate and SCF Input Example (Bash) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/file_formats/turbomole.rst.txt A simplified Turbomole input file example demonstrating the $coord, $basis, and $scf sections. The $coord block defines atomic positions, $basis is for basis set details (omitted here), and $scf sets convergence parameters for the self-consistent field calculation. This serves as a basic template for Turbomole calculations. ```bash $coord 0.000000 0.000000 0.000000 O 0.757000 0.586000 0.000000 H -0.757000 0.586000 0.000000 H $end $basis * basis set details for each element * $end $scf maxiter 200 conver 1.0e-6 $end ``` -------------------------------- ### Install pyCOFBuilder using Pip (Bash) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/install.rst.txt Installs the pyCOFBuilder package from the Python Package Index (PyPI) using pip. This is the recommended and simplest method for installing the package once the environment is set up and activated. Ensure pip is available in your activated environment. ```bash pip install pycofbuilder ``` -------------------------------- ### GJF: Water molecule optimization (B3LYP/6-31G(d)) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/file_formats/gjf.rst.txt Shows a minimal, working GJF for optimizing a water molecule using B3LYP/6-31G(d). It contains a route line (method, basis, calculation type), charge/multiplicity, atomic coordinates (O and two H), and Tv cell vectors. This example is suitable as a starting point for simple geometry optimizations in Gaussian. ```bash #P B3LYP/6-31G(d) Opt M 0 1 O 0.00000 0.00000 0.00000 H 0.75700 0.58600 0.00000 H -0.75700 0.58600 0.00000 Tv 5.00000 0.00000 0.00000 Tv 0.00000 5.00000 0.00000 Tv 0.00000 0.00000 5.00000 ``` -------------------------------- ### PyCofbuilder Setup Configuration Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/src/pycofbuilder.egg-info/SOURCES.txt This snippet represents the setup.py file, a traditional Python script for defining package metadata, dependencies, and build instructions. It's used for packaging and distributing the PyCofbuilder library. ```python from setuptools import setup setup( name='pycofbuilder', version='0.1.0', packages=['pycofbuilder'], install_requires=[ 'numpy', 'scipy', 'pandas', 'ase', 'pymatgen' ], entry_points={ 'console_scripts': [ 'pycofbuilder=pycofbuilder.cli:main', ] }, ) ``` -------------------------------- ### XSF Crystal Structure Example Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/file_formats/xsf.rst.txt A simplified example of an XSF file representing a crystal structure. It includes primitive vectors and atomic coordinates in fractional format. This is a text-based format primarily used by Xcrysden. ```bash CRYSTAL PRIMVEC 5.0 0.0 0.0 0.0 5.0 0.0 0.0 0.0 5.0 PRIMCOORD 1 O 0.00000 0.00000 0.00000 H 0.50000 0.50000 0.00000 H 0.50000 0.00000 0.50000 H 0.00000 0.50000 0.50000 END ``` -------------------------------- ### Import and Print PyCofbuilder Version in Python Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/pyCOFBuilder_example.ipynb This Python script demonstrates how to import the pycofbuilder library and access its version information. It relies on the pycofbuilder package being successfully installed in the environment. The script prints the installed version to the console. ```python import os import pycofbuilder as pcb print("Running pyCOFBuilder version:", pcb.__version__) ``` -------------------------------- ### XYZ File Structure Example Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/file_formats/xyz.rst Illustrates the basic structure of an XYZ file, including the atom count, an optional comment line, and the element with its X, Y, Z coordinates for each atom. ```bash Number of atoms Comment line (optional) Element1 x1 y1 z1 Element2 x2 y2 z2 ... ElementN xN yN zN ``` -------------------------------- ### Extended XYZ File Example with Lattice and Properties Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/file_formats/xyz.rst Demonstrates an extended XYZ file format, incorporating lattice vectors and a detailed 'Properties' string that specifies atomic species, position, and other attributes. ```bash 5 Lattice="5.44 0.0 0.0 0.0 5.44 0.0 0.0 0.0 5.44" Properties=species:S:1:pos:R:3 Time=0.0 O 0.00000 0.00000 0.00000 H 0.75700 0.58600 0.00000 H -0.75700 0.58600 0.00000 ``` -------------------------------- ### Create Conda Environment for pyCOFBuilder (Bash) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/install.rst.txt This command creates a new conda environment using the specified 'environment.yml' file. This file is expected to contain all the necessary dependencies for pyCOFBuilder. Ensure you have conda installed and 'environment.yml' is in your current directory. ```bash conda env create --file environment.yml ``` -------------------------------- ### Activate Conda Environment (Bash) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/install.rst.txt Activates the conda environment named 'pycofbuilder'. This command must be run before installing or executing pyCOFBuilder to ensure that the correct dependencies are loaded. The environment name should match the one created in the previous step. ```bash conda activate pycofbuilder ``` -------------------------------- ### Load Building Blocks for COF Construction Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/pyCOFBuilder_example.ipynb This Python snippet demonstrates how to load custom building blocks for COF synthesis using the pcb library. It initializes a BuildingBlock object for 'T3_BENZ_CHO_OH' and loads another from a Gaussian input file ('PSAF.gjf'). ```python bb_t3 = pcb.BuildingBlock('T3_BENZ_CHO_OH') bb_l2 = pcb.BuildingBlock() bb_l2.from_file('.', 'PSAF.gjf') ``` -------------------------------- ### Manually Import pyCOFBuilder Module (Python) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_sources/first_steps/install.rst.txt Demonstrates how to manually import the pyCOFBuilder module into a Python script. This involves appending the source directory of the pyCOFBuilder package to the system path using `sys.path.append()`. Replace '{PATH_TO_PYCOFBUILDER}' with the actual path to your downloaded package. ```python # importing module import sys # appending a path sys.path.append('{PATH_TO_PYCOFBUILDER}/pyCOFBuilder/src') import pycofbuilder as pcb ``` -------------------------------- ### Example XYZ Line with Extended Properties Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/file_formats/xyz.rst Shows a single atom line in an extended XYZ file, adhering to the 'Properties' definition. It includes the element symbol, coordinates, velocity, and a 'select' integer. ```bash Si 4.08000000 4.08000000 1.36000000 0.00000000 0.00000000 0.00000000 1 ``` -------------------------------- ### Create T3 building block example in XYZ, Gaussian, and ChemicalJSON formats Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/custom_building_blocks.rst Provides example content for the T3 building block in three file formats used by pycofbuilder: XYZ, Gaussian input (.gjf), and ChemicalJSON. These snippets include atomic coordinates and element types needed to generate COF structures. No external dependencies are required beyond the file format specifications. ```XYZ 9 T3 building block C 0.9828406 0.9992759 0.0000000 C -0.3739780 1.3508029 0.0000000 C -1.3568187 0.3515270 0.0000000 C -0.9828406 -0.9992759 0.0000000 C 0.3739780 -1.3508029 0.0000000 C 1.3568187 -0.3515270 0.0000000 C -1.9996089 -2.0330469 0.0000000 H -1.8107021 -3.1273182 0.0000000 C 2.7604747 -0.7151886 0.0000000 H 3.6136881 -0.0044549 0.0000000 C -0.7608658 2.7482355 0.0000000 H -1.8029860 3.1317731 0.0000000 O 1.9855845 2.0187880 0.0000000 H 1.7077038 3.0013254 0.0000000 O -2.7411139 0.7101726 0.0000000 H -3.4530759 -0.0217478 0.0000000 O 0.7555294 -2.7289606 0.0000000 H 1.7453721 -2.9795776 0.0000000 X 0.0000000 3.7112465 0.0000000 X -3.2140338 -1.8556233 0.0000000 X 3.2140338 -1.8556233 0.0000000 ``` ```Gaussian (.gjf) # hf/3-21g T3 building block 0 1 C 0.9828406 0.9992759 0.0000000 C -0.3739780 1.3508029 0.0000000 C -1.3568187 0.3515270 0.0000000 C -0.9828406 -0.9992759 0.0000000 C 0.3739780 -1.3508029 0.0000000 C 1.3568187 -0.3515270 0.0000000 C -1.9996089 -2.0330469 0.0000000 H -1.8107021 -3.1273182 0.0000000 C 2.7604747 -0.7151886 0.0000000 H 3.6136881 -0.0044549 0.0000000 C -0.7608658 2.7482355 0.0000000 H -1.8029860 3.1317731 0.0000000 O 1.9855845 2.0187880 0.0000000 H 1.7077038 3.0013254 0.0000000 O -2.7411139 0.7101726 0.0000000 H -3.4530759 -0.0217478 0.0000000 O 0.7555294 -2.7289606 0.0000000 H 1.7453721 -2.9795776 0.0000000 X 0.0000000 3.7112465 0.0000000 X -3.2140338 -1.8556233 0.0000000 X 3.2140338 -1.8556233 0.0000000 ``` ```ChemicalJSON { "chemical json": 1, "name": "T3_BENZ_CHO_OH", "formula": "C9O3H6X3", "atoms": { "elements": { "type": [ "C", "C", "C", "C", "C", "C", "C", "X", "H", "C", "X", "H", "C", "X", "H", "O", "H", "O", "H", "O", "H" ], "number": [ 6, 6, 6, 6, 6, 6, 6, 0.0, 1, 6, 0.0, 1, 6, 0.0, 1, 8, 1, 8, 1, 8, 1 ] }, "coords": { "3d": [ 0.9828406, 0.9992759, 0.0, -0.373978, 1.3508029, 0.0, -1.3568187, 0.351527, 0.0, -0.9828406, -0.9992759, 0.0, 0.373978, -1.3508029, 0.0, 1.3568187, -0.351527, 0.0, -1.9996089, -2.0330469, 0.0 ] } } } ``` -------------------------------- ### Visualize Building Block Structure with RDKit Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/examples/BuildingBlock_creation/create_building_block.ipynb Visualizes the structure of a building block using RDKit's Chem and Draw modules. This requires RDKit to be installed in the environment. The visualization uses the xSMILES and xSMILES label properties of the building block. ```python from rdkit import Chem from rdkit.Chem import Draw # Assuming new_BB object and its properties are defined from previous step scaffold = Chem.MolFromSmiles(new_BB.properties['xsmiles'] + ' ' + new_BB.properties['xsmiles_label']) Draw.MolToImage(scaffold, legend=new_BB.name, size=(400, 200)) ``` -------------------------------- ### Write Gaussian Input File for Phenosafranin Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/pyCOFBuilder_example.ipynb This Python snippet writes a multi-line string containing the molecular geometry and basis set information for phenosafranin into a Gaussian input file named 'PSAF.gjf'. This file serves as the input for computational chemistry software. ```python PSAF_gjf = """# hf/3-21g Title Card Required 0 1 C -6.16740438 -1.81989570 -0.01291600 C -4.80278138 -1.81989570 -0.01291600 C -4.06989038 -0.58867470 -0.01291600 C -4.79388738 0.64307230 -0.01843400 C -6.22612738 0.60158130 -0.01973400 C -6.88991038 -0.59071170 -0.01636300 C -2.69456938 1.87712330 -0.01453000 C -1.97060038 0.64542030 -0.00711000 C -0.53841838 0.68704430 0.00000000 H 0.00745162 -0.26848270 0.00660100 C 0.12531862 1.87939930 0.00104200 C -0.59716438 3.10851430 -0.00713000 C -1.96180738 3.10836930 -0.01449700 H -4.23345538 -2.76162970 -0.00981000 H -6.77194038 1.55712730 -0.02433800 H -7.98930838 -0.62687670 -0.01779400 H -0.03108438 4.05169130 -0.00603500 H -2.53135038 4.04998630 -0.02076900 X -7.07794753 -3.33772185 -0.00904773 X 1.89434776 1.93717161 0.01095392 N -4.09351038 1.85423930 -0.02015500 N -2.67098938 -0.56578570 -0.00802000 C -1.92634194 -1.83321102 -0.00225325 C -2.30569014 -2.86898284 -0.85650329 C -0.84048284 -2.00031769 0.85712648 C -1.59969910 -4.07179876 -0.85082661 H -3.16228175 -2.73720244 -1.53335373 C -0.13356069 -3.20308323 0.86222567 H -0.54125111 -1.18400730 1.53034765 C -0.51305371 -4.23882140 0.00854630 H -1.89903489 -4.88847665 -1.52368012 H 0.72280381 -3.33440532 1.53962407 H 0.04347932 -5.18726708 0.01280321 Cl -3.42716036 -4.50814402 -0.13846518""" with open('PSAF.gjf', 'w') as f: f.write(PSAF_gjf) ``` -------------------------------- ### Setup Grid Event Listener (JavaScript) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/building_blocks/T3.html Initializes support for selection UI and attaches an event listener to reinitialize grid interactions whenever the grid updates. Depends on jQuery for the event binding and assumes listObj is defined. ```javascript var supportSelection = eval('True'.toLowerCase()); listObj.on("updated", initInteraction); ``` -------------------------------- ### RDKit Module Initialization and Search Setup Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/img/mol2grid_H6.html Initializes RDKit module and sets up the environment for molecular processing. Creates global RDKit references and defines SMARTS search functionality that validates queries against molecular structures. Handles molecular matching and item visibility based on search results. ```javascript var smarts_matches = {}; // Load RDKit window .initRDKitModule() .then(function(RDKit) { console.log('RDKit version: ', RDKit.version()); window.RDKit = RDKit; window.RDKitModule = RDKit; // Searchbar function SmartsSearch(query, columns) { var smiles_col = columns[0]; smarts_matches = {}; var query = $('#mols2grid .m2g-searchbar').val(); var qmol = RDKit.get_qmol(query); if (qmol.is_valid()) { listObj.items.forEach(function (item) { var smiles = item.values()[smiles_col] var mol = RDKit.get_mol(smiles, '{"removeHs": false }'); if (mol.is_valid()) { var results = mol.get_substruct_matches(qmol); if (results === "{}") { item.found = false; } else { item.found = true; } } else { item.found = false; } mol.delete(); }); } qmol.delete(); } ``` -------------------------------- ### Example CJSON File for Rutile Crystal Structure Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/first_steps/file_formats/cjson.rst This is a simplified example of a Chemical JSON (CJSON) file representing the crystal structure of Rutile (TiO2). It includes information about the chemical name, formula, unit cell parameters, and atomic coordinates. ```json { "chemical json": 0, "name": "TiO2 rutile", "formula": "Ti 2 O 4", "unit cell": { "a": 2.95812, "b": 4.59373, "c": 4.59373, "alpha": 90.0, "beta": 90.0, "gamma": 90.0 }, "atoms": { "elements": { "number": [ 22, 22, 8, 8, 8, 8 ] }, "coords": { "3d fractional": [ 0.00000, 0.00000, 0.00000, 0.50000, 0.50000, 0.50000, 0.00000, 0.30530, 0.30530, 0.00000, 0.69470, 0.69470, 0.50000, 0.19470, 0.80530, 0.50000, 0.80530, 0.19470 ] } } } ``` -------------------------------- ### Create and Save COF Framework Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/pyCOFBuilder_example.ipynb This Python code constructs a Covalent Organic Framework (COF) using two pre-defined building blocks (`bb_t3` and `bb_l2`). It assigns a framework name ('HCB_A') and a topology ('AA'), then saves the resulting COF structure in CIF format. ```python cof = pcb.Framework() cof.from_building_blocks(bb_t3, bb_l2, 'HCB_A', 'AA') cof.save(fmt='cif') ``` -------------------------------- ### PDB File Format Example - pyCOFBuilder Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/first_steps/file_formats/pdb.html A simplified example of a Protein Data Bank (PDB) file structure used to represent a crystal structure of a small molecule. This format includes header, unit cell information, atomic coordinates, and an end marker. ```pdb HEADER SMALL MOLECULE CRYSTAL STRUCTURE CRYST1 5.0 5.0 5.0 90.00 90.00 90.00 P 1 1 ATOM 1 O HOH A 1 0.000 0.000 0.000 1.00 0.00 ATOM 2 H1 HOH A 1 0.500 0.500 0.000 1.00 0.00 ATOM 3 H2 HOH A 1 0.500 0.000 0.500 1.00 0.00 ATOM 4 H3 HOH A 1 0.000 0.500 0.500 1.00 0.00 END ``` -------------------------------- ### Molecular grid initialization with List.js Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/img/mol2grid_Q.html Initializes a molecular grid using List.js library with custom configuration. Handles molecular data display including SMILES strings, codes, and SVG representations. Includes pagination and interactive elements. ```JavaScript var listObj = new List('mols2grid', { listClass: 'm2g-list', valueNames: [{data: ['mols2grid-id']}, 'data-Code', 'data-img', 'data-Name', 'data-mols2grid-id', 'data-SMILES', 'data-mols2grid-id-display', {attr: 'data-content', name: 'm2g-tooltip'}], item: '
i
', page: 12, pagination: { paginationClass: "m2g-pagination", item: '
  • ', innerWindow: 1, outerWindow: 1 } }); listObj.remove("mols2grid-id", "0"); listObj.add([{"data-Code": "COOH", "data-img": "\n\n\n \n\n\n\n\n\n\n\n\n\n\n tuple: """ 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 """ # This function's implementation is incomplete in the provided snippet. # It requires further logic to calculate kx, ky, kz based on cell and distance. pass # Placeholder for incomplete function ``` -------------------------------- ### Generate Quantum Espresso Input File (Python) Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_modules/pycofbuilder/io_tools.html This code snippet demonstrates the generation of a Quantum Espresso input file using Python. It constructs a dictionary containing all the necessary parameters and then writes them to a .pwscf file. The code adapts to different calculation types and includes options for automatic k-point grid generation. ```Python if len(cell) == 6: cell_matrix = cellpar_to_cell(cell) else: cell_matrix = cell ibrav_dict = cell_to_ibrav(cell_matrix) input_dict = {} input_dict['control'] = { 'prefix': f"'{file_name}'", 'calculation': f"{calc_type}", 'restart_mode': "'from_scratch'", 'wf_collect': ".true.", 'pseudo_dir': "'$PSEUDO_DIR'", 'outdir': "'$SCRATCH_DIR'", 'verbosity': "'high'", 'tstress': ".true.", 'tprnfor': ".true.", 'etot_conv_thr': '1.0d-5', 'forc_conv_thr': '1.0d-6', 'nstep': 1000} input_dict['system'] = { 'nat': len(atom_types), 'ntyp': len(set(atom_types)), 'ecutwfc': 40, 'ecutrho': 360, 'vdw_corr': "'grimme-d3'", 'occupations': "'smearing'", **ibrav_dict} input_dict['electrons'] = { 'conv_thr': 1.0e-9, 'electron_maxstep': 100, 'mixing_beta': 0.3} if calc_type == 'vc-relax': input_dict['ions'] = { 'ion_dynamics': "'bfgs'"} input_dict['cell'] = { 'cell_dynamics': "'bfgs'", 'cell_dofree': "'all'"} # If the kpoints grid is not specified, calculate it automatically if 'k_points' not in input_dict.keys(): if 'kspacing' not in input_dict.keys(): input_dict['kspacing'] = kspacing input_dict['kpoints'] = get_kgrid(cell_matrix, input_dict['kspacing']) with open(os.path.join(path, file_name + '.pwscf'), 'w') as f: f.write('&CONTROL\n') for key in input_dict['control']: f.write(f" {key} = {input_dict['control'][key]} \\n") f.write('/\n\\n') f.write('&SYSTEM\n') for key in input_dict['system']: f.write(f" {key} = {input_dict['system'][key]} \\n") f.write('/\n\\n') f.write('&ELECTRONS\n') for key in input_dict['electrons']: f.write(f" {key} = {input_dict['electrons'][key]} \\n") f.write('/\n\\n') if calc_type == 'vc-relax': f.write('&IONS\n') for key in input_dict['ions']: f.write(f" {key} = {input_dict['ions'][key]} \\n") f.write('/\n\\n') f.write('&CELL\n') for key in input_dict['cell']: f.write(f" {key} = {input_dict['cell'][key]} \\n") f.write('/\n\\n') f.write('ATOMIC_SPECIES\n') for atom in set(atom_types): f.write(f" {atom} {elements_dict()[atom]:>9.5f} {atom}.PSEUDO.UPF\\n") f.write('\\n') # f.write('CELL_PARAMETERS (angstrom) \n') # for v in cell_matrix: # f.write(f'{v[0]:>15.9f} {v[1]:>15.9f} {v[2]:>15.9f}\n') # f.write('\\n') if frac_coords: coords_type = 'crystal' else: coords_type = 'angstrom' f.write(f'ATOMIC_POSITIONS ({coords_type})\\n') for i, atom in enumerate(atom_pos): f.write('{:<5s}{:>15.9f}{:>15.9f}{:>15.9f} ! {:5}\n'.format(atom_types[i], atom[0], atom[1], atom[2], atom_labels[i])) f.write('\\n') f.write('K_POINTS automatic\n') ``` -------------------------------- ### Get Number of Atoms Source: https://github.com/lipelopesoliveira/pycofbuilder/blob/master/docs/_build/html/_modules/pycofbuilder/building_block.html Returns the total number of atoms present in the BuildingBlock's unitary cell. This is determined by the length of the `atom_types` list, which presumably stores the type of each atom. ```python def n_atoms(self): ''' Returns the number of atoms in the unitary cell''' return len(self.atom_types) ```