A one-stop guide to teach chemists how to use Python for coding and iterations in a hands-on and practical manner
Key Features
● Understand the core Python functions and algorithms for the computation of chemical parameters.
● Learn how to use Cheminformatics modules to process and analyze elemental data and molecular structures.
● Get familiar with the algorithms for numerical and symbolic computations.
Description
Python is a versatile and powerful computer language without a steep learning curve. It can be deployed to simulate various physicochemical parameters or to analyze complex molecular, bio-molecular, and crystalline structures.
The objective of this book is to give a gentle introduction to Python programming with relevant algorithms, iterations, and basic simulations from a chemist’s perspective. This book outlines the fundamentals of Python coding through the built-in functions, libraries, and modules as well as with a few selected external packages for physical/materials/inorganic/analytical/organic/ nuclear chemistry in terms of numerical, symbolic, structural, and graphical data analysis using the default, Integrated Development and Learning Environment. You will also learn about the Structural Elucidation of organic molecules and inorganic complexes with specific Cheminformatics modules. In addition to this, the book covers chemical data analysis with Numpy and also includes topics such as SymPy and Matplotlib for Symbolic calculations and Plotting.
By the end of the book, you will be able to use Python as a graphical tool or a calculator for numerical and symbolic computations in the interdisciplinary areas of chemistry.
What you will learn
● To fetch elemental, nuclear, atomic or molecular data with list or dictionary functions.
● Understanding the algorithms for the computation of Thermodynamic, Electrochemical, Kinetics, Molecular and Spectral parameters.
● Stoichiometrical calculation of the reactant and product coefficients from Matrices.
● Symbolic computations with reference to Physical Chemistry.
● With Matplotlib package, interpretation and plotting of the analyzed data in the desired graphical format.
● With various cheminformatics modules, correlate the structure of complex and bulkier molecules.
Who this book is for
This book is for Chemists, Chemical Engineers, Material Scientists, Bio-chemists, Biotechnologists, and Physicists. Students of Chemistry, Chemical Engineering, Materials Chemistry, Biochemistry, Biotechnology, and Physics will find this book resourceful.
Author(s): Dr. M. Kanagasabapathy
Publisher: BPB Publications
Year: 2023
Language: English
Pages: 206
1. Understanding Python Functions for Chemistry
Introduction
Structure
Dictionary for atomic numbers and atomic masses
Adding elements to the dictionary
Updating elements in the dictionary
Deleting elements from the dictionary
Atomic mass percentage from molecular formula
Data module for physical and chemical constants
Molar gas constant from Boltzmann’s constant
Estimation of volume of an ideal gas
Quantum efficiency of photochemical reactions
Fetching R f data of amino acids from .csv file
Fetching selective data for amino acids from .csv file
Converting 'amino_acids.csv' to dictionary
Estimation of rate constant with data as a list
Exporting rate constant data to .csv
math module
Power of 10 (e)
pH metric acid-base titration
R.M.S and average velocity of ideal gas molecules
Rate constant from activation energy
Calculating sine (angle) from radians
Estimating bond length from the bond angle
Priority for arithmetical operators
Quotient and modulo operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
cmath module
Scrutinizing user input data
Tackling of errors in user inputs
Number of electrons transferred in a redox reaction
Conditions and loops
if … elif … else statements
Error handling with if … else loops
Nested loops
while loops
for loops
range() function
Fetching selective rows of amino_acid.csv file
timer() function
Recording concentration with time (reaction rate)
Recursion
Predicting spin–spin coupling in NMR spectra
Lambda function
Conclusion
2. Computations in Chemistry with NumPy
Introduction
Structure
Why NumPy
Dimension in arrays
Indexing for arrays
Negative indexing
Shape of an array
Reshaping the arrays
Slicing of arrays
Iterating the arrays
Entropy calculation for Beryllium compounds
Concatenating arrays
Concatenating 1-D arrays
Concatenating based on axis values
np.stack() function with axis 0 and 1
Stacking arrays along rows, columns, and height
Transpose of arrays
Distribution coefficient for phenol
Association factor of phenol in H 2 O and CHCl 3 75
Important functions in NumPy
Balancing equation by matrix row echelon form
Solving systems of linear equations
Equilibrium reactions and Quadratic equation
Coefficients for 3 rd order polynomial equations
Interpolations for unknown variables
Reading and writing .csv file
Lagrange interpolation – Viscosity of glycerol
Basics of Lagrange interpolation
3 rd order polynomial fit for viscosity of glycerol
Conclusion
3. Interpolation, Physico-chemical Constants, and Units with SciPy
Introduction
Structure
SciPy for scientific computations
Built-in scientific constants
List of scientific constants
Default unit for physical and chemical constants
Base units for physical and chemical constants
Interconversion of units
SI prefixes
Binary prefixes
Current density – Electrochemical deposition of Cu
Interconversion of units of pressure
Interconversion of units of time
Interconversion of units of length
Interconversion of units of angle
Interconversion of units of temperature
Interconversion of units of energy
Interconversion of units of power
Interconversion of units of force
Interconversion of units of different dimensions
Interconversion of temperature units
Sub packages
SciPy Integration
Integration with quad
Integration with romberg
Integration in NMR spectra – number of H atoms
Roots of an equation
Interpolation of viscosity of glycerol
Cubic splines for irregular intervals with three data points
Cubic splines for irregular intervals with higher accuracy
Cubic Spline interpolation – Viscosity of glycerol
Solving system of linear equations
Straight line curve fitting – II order reactions
Balancing chemical equations with matrices – Combustion of hexane
Finding minima for a function – Vapor pressure
Statistical functions
Conclusion
4. SymPy for Symbolic Computations in Chemistry
Introduction
Structure
Why SymPy
Basics of symbolic calculations
Differential derivatives with diff() module
Integration with integrate() module
Solving equations
Matrix operations
Binomial functions
Sets
Rate of a formation of CH 3 COOH by fermentation from I derivative
Estimation of charge in an electrochemical cell – Definite integral
Stoichiometric coefficient of a reaction – Matrix row echelon form
Solving simultaneous arbitrary equations for concentrations
Equilibrium reactions and quadratic equation
Conclusion
5. Interactive Plotting of Physico-chemical Data with Matplotlib
Introduction
Structure
Why Matplotlib
2D line graph
Optimizing marker styles
Optimizing line styles
Font style
Grid lines
Tick marks
Tick mark intervals
Subplot
Multiple data sets in a plot
Data legend
Bar charts
Bar chart for thermodynamic parameters
Pie chart – Composition of electrodeposited Ni-Co magnetic alloy
Conclusion
6. Introduction to Cheminformatics with RDKit
Introduction
Structure
Installation and importing RDKit
Chemical structure from SMILES
Structure of molecule from .mol file
Conversion of .mol to SMILES
Kekule form of SMILES
SMILES to .mol blocks
Saving .mol in local directory
Fetching number of atoms
Fetching individual atoms
Fetching bond types
Position in ring (Boolean)
Ring size (Boolean)
Working with .sdf formats
Stereochemical notation in molecules
Highlighting bonds and atoms
Conclusion
7. ChemFormula for Atomic and Molecular Data
Introduction
Structure
Installation and importing ChemFormula
Formats for molecular formula
To check radioactivity (Boolean)
Fetching number of individual elements
Estimation of molar / atomic mass
Mass fraction / atomic percentage
Calculating elemental fractions in %
Conclusion
8. Chemlib for Physico-chemical Parameters
Introduction
Structure
Installation and importing chemlib
Fetching elemental data
Molar mass and atomic percentage
Number of moles and molecules
Empirical formula
Combustion reaction
Balancing the chemical equation
Finding limiting reagent
pH and pOH
Molarity calculation
Electrode potential of an electrochemical cell
Electrolysis
Cathodic current efficiency (CCE)
Frequency and wavelength of electromagnetic radiation
Energy of an electron in Bohr orbital
Conclusion
9. ChemPy for Computations in Chemistry
Introduction
Structure
Installation and importing ChemPy
Fetching molar mass of compounds
LaTeX, Unicode and .html formats
Balancing the chemical equation
Stoichiometric molar mass fractions
Balancing equations of ionic equilibria
Ionic strength
.chemistry.Reaction module
Web publishing the reaction
LaTeX form for reactions
Unicode form for reactions
Number of phases
Reaction rates
Segregating elements with atomic number
Derived units
.kinetics.arrhenius module
Conclusion
10. Mendeleev Package For Atomic and Ionic Data
Introduction
Structure
Installation and importing Mendeleev
Fetching properties of element
Fetching oxidation states of an element
Ionization energies of an element
Fetching isotopic parameters
Fetching ionic radii and crystal radii
Effective nuclear charge
Electronegativity
Fetching elemental data
Conclusion
11. Computations of Parameters of Electrolytes with PyEQL
Introduction
Structure
Installation and importing pyEQL
Density of the solutions
Specific conductance
Ionic strength
Weight of the ionic components
Activity coefficients
Diffusion coefficients
Functions related to molecular formula
Solution parameters
Simulation of ionic conductance
Osmotic pressure
Data for kinematic and dynamic viscosities
Units for ionic concentration
Conclusion
12. STK Module for Molecular Structures
Introduction
Structure
Installation and importing stk
Molecule with a specific functional group more than one
Constructing polymeric reaction from monomers
Constructing cage structures
Optimizing the structure of molecules with rdkit
Covalent organic frameworks
Metal complexes
Conclusion