Fundamental Chemistry with Matlab

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Most developers today use the so called ‘ third-generation languages’ such as C, C++, Python, and Java. A third-generation language, a general purpose language in nature, gives the developer the kind of precise control needed to write exceptionally fast applications that can perform a wide array of tasks. Fourth-generation languages, like Matlab (short for Matrix Laboratory), on the contrary, are designed with a specific purpose in mind, which in the case of Matlab, is scientific and technical computing. In this sense, it has been designed for empowering the user to work with heterogeneous collections of data, rather than individual variables, making it easier for the user to focus on the task, instead on the language. As programming languages progress through generations, they become more intelligible and closer to human abstraction and language. Matlab took advantage since the early developments of the abstraction levels inherent in the mathematical language and operations, thus offering the user a mathematical environment suitable to any hardware and operating system platform. Subsequent developments added graphical environments like that of Simulink devoted to dynamic systems and their automatic control (to be employed in Chapters 3 and 4), Graphical user interfaces (GUI), document editing, and a rich set of toolboxes covering a wide spectrum of scientific and technical computing and real-time applications in measurements and control. The chemistry computations proposed in the book will just employ the Matlab core, without any reference to Matlab toolboxes. To this end, we will exploits functions of the following areas: Algebra, Linear algebra (many equations dealing with many unknowns), Calculus, Differential equations, Optimization, Linear regression, Statistics, Curve fitting, Graphing. Code listing in this book is specifically designed to work on Matlab platform, however with a little efforts most of the simple scripts can be exported to Octave, a very similar but free platform. Indeed if you are looking for an open-source environment close to Matlab in terms of compatibility and computational ability, then Octave is the best alternative. It runs on any operating system without any modifications. Scilab is another open-source option for numerical computing which runs across all the major platforms. Like Octave it is very similar to Matlab in its implementation, although exact compatibility is not a goal of the project developers. It has the advantage of possessing a graphical interface similar to Simulink, named Xcos.

Author(s): Daniele Mazza, Enrico Canuto
Edition: 1
Publisher: Elsevier
Year: 2022

Language: english
Pages: 329
Tags: Chemistry, Computer Science, Matlab, algorithms

Front Cover
Fundamental Chemistry With Matlab
Copyright Page
Dedication
Contents
Introduction
Matlab language and environment
The Matlab scripts
The book topics
Group one: atomic orbitals
Plotting atomic orbitals with Matlab (Chapter 1)
Group two: stoichiometry and kinetics
Balancing chemical reactions with Matlab (Chapter 2)
Chemical kinetics aided by Matlab/Simulink (Chapter 3)
More complex kinetics aided by Matlab/Simulink (Chapter 4)
Group three: gases and vapors
Gaseous reactions and equilibria aided by Matlab (Chapter 5)
Physical properties of gases and vapors aided by Matlab (Chapter 6)
Group four: aqueous solutions
Exploring acid–base equilibria in water with Matlab (Chapter 7)
Colligative properties of solutions aided by Matlab (Chapter 8)
Exploring seawater chemical equilibria with Matlab (Chapter 9)
Prevalence diagrams for some common elements aided by Matlab (Chapter 10)
Appendices
Authorship and acknowledgments
Measurement units and universal constants
Standard conditions for temperature and pressure
Notations
Abbreviations
References
1 Plotting atomic orbitals with Matlab
1.1 Wave functions and their factorization
1.1.1 Generalities
1.1.2 Angular wave functions
1.1.3 Table of the radial functions
1.2 Graphical plot of the wave functions
1.3 Graphical algorithm
1.3.1 Description
1.3.2 Matlab script
1.4 Graphical plot of the radial probability density for s-type orbitals
1.4.1 Description
1.4.2 Matlab script and graphical results
1.5 Hybrid orbitals
1.5.1 Hybrid orbitals sp3
1.5.2 Hybrid orbitals dsp3
1.5.3 Hybrid orbitals d2sp3
References
2 Balancing chemical reactions with Matlab
2.1 Introduction
2.2 Nonredox and redox reactions
2.2.1 Nonredox reactions (or metatheses)
2.2.2 Redox reactions
2.2.3 Stoichiometry and nonredox reactions
2.2.4 Stoichiometry and redox reactions
2.3 General method
2.3.1 The balance equation
2.3.2 Example
2.4 Solution of the homogeneous system of linear equations
2.4.1 The nullspace method
2.4.2 Example
2.4.3 Balancing algorithm from chemical formulas
2.5 Nullspace algorithm for balancing chemical reactions
2.5.1 Nullspace function stoichiometry
2.5.2 Results of the plug-in code example
2.6 Catalog of the reactions and of their plug-in codes
2.6.1 Oxidation of hydrogen peroxide by potassium permanganate
2.6.2 Oxidation of silver sulfide by aqua regia
2.6.3 Oxidation of bromidric acid by potassium dichromate
2.6.4 Oxidation of mercury by nitric and chloridric acid
2.6.5 Oxidation of chromium(II) bromide by sodium bromate
2.6.6 Zinc oxidation by silver arseniate
2.6.7 Precipitation of an insoluble salt (AgCl)
2.6.8 Neutralization of carbonic acid with sodium hydroxide
2.6.9 Hydrolysis of sodium carbonate with nitric acid
2.6.10 Oxidation of sodium sulfite to sulfate by potassium permanganate
2.6.11 Oxidation of iron(II) sulfate by hydrogen peroxide in acid solution
2.6.12 Oxidation of manganese(II) chloride to potassium permanganate by sodium bromate
References
3 Chemical kinetics aided by Matlab/Simulink
3.1 Introduction
3.2 First-order irreversible kinetics
3.2.1 State equation construction
3.2.2 Simulink graphical representation
3.2.3 The Matlab script
3.2.4 A simpler alternative Matlab script
3.3 First-order reversible reaction
3.3.1 State equation construction
3.3.2 Simulink graphical representation and results
3.3.3 Alternative Matlab script
3.4 Second-order reversible reaction
3.4.1 State equations
3.4.2 Solution of the Riccati equation
3.4.3 Alternative Matlab script
3.5 Consecutive irreversible reactions
3.5.1 State equations
3.5.2 Alternative Matlab script
3.6 Two-stage NO to NO2 oxidation
3.6.1 State equations
3.6.2 Alternative Matlab script
3.7 Ozone decomposition into oxygen
3.7.1 State equations
3.7.2 Alternative Matlab script
3.8 Irreversible A → B reaction with linear temperature increase
References
4 More complex kinetics aided by Matlab/Simulink
4.1 Introduction
4.2 Michaelis–Menten kinetics
4.2.1 State equations, equilibrium, and stability
4.2.2 The Michaelis–Menten equation of the production rate
4.2.3 Script, block diagram and graphical results
4.3 The iodine clock reaction
4.3.1 State equations
4.4 Oscillating kinetics: introduction
4.4.1 The Lotka–Volterra model
4.5 Oscillating kinetics of Briggs–Rauscher
4.5.1 Simplified reaction scheme
4.5.2 State equations and stability analysis
4.5.3 Behavior of the state equations
4.6 Introduction to Belousov–Zhabotinsky kinetics
4.6.1 State equations
4.6.2 Equilibrium and stability analysis
4.6.3 Simulated results
4.6.4 Matlab script
References
5 Gaseous reactions and equilibria aided by Matlab
5.1 The second law of thermodynamics
5.2 Application of the Gibbs energy criterion to chemical reactions
5.3 Relationship of ΔG with the equilibrium constant KP
5.4 The value of ΔS, ΔH, and ΔG as a function of temperature
5.5 The table of the NASA CEA thermochemical coefficients
5.6 Introduction to Matlab scripts
5.6.1 Organization of the Matlab scripts
5.6.2 The function NASAdata
5.6.3 The function ThermoCoef
5.7 Hydrogen combustion
5.7.1 Description
5.7.2 The Matlab script
5.8 Ammonia synthesis (Haber process)
5.8.1 Description and graphical plot
5.8.2 The Matlab script
5.9 Methane (CH4) combustion
5.9.1 Description and graphical plot
5.9.2 Matlab script
5.10 Hydrogen production at high and low temperature
5.10.1 Description and graphical plot
5.10.2 Matlab script
5.11 Sulfur trioxide (SO3) production from sulfur dioxide (SO2)
5.11.1 Description and graphical profiles
5.11.2 Matlab script
5.12 CaSO4 production from lime and sulfur impurity in clean coal combustion
5.12.1 Description and graphical results
5.12.2 Matlab script
5.13 Calcium carbonate (CaCO3) decomposition and kinetics
5.13.1 Description and graphical plot
5.13.2 Matlab script
References
6 Physical properties of gases and vapors aided by Matlab
6.1 Introduction
6.2 Distribution of molecular velocities in the case of oxygen
6.2.1 Description and graphical results
6.2.2 Matlab script
6.3 Compressibility of a real gas
6.3.1 Description and graphical results
6.3.2 Matlab script
6.4 van der Waals isotherm of real gases
6.4.1 Description and graphical results
6.4.2 Matlab script
6.5 Water vapor pressure
6.5.1 Description and graphical results
6.5.2 Matlab script
6.6 Water vapor pressure at different altitude and humidity
6.6.1 Description and graphical results
6.6.2 Matlab script
References
7 Exploring with Matlab acid–base equilibria in water
7.1 The hydrogen ion in solution
7.2 Monoprotic acid
7.2.1 Description and results
7.2.2 Matlab script
7.3 Biprotic acid
7.3.1 Description and results
7.3.2 Matlab script
7.4 Titration of a weak biprotic acid with a strong base
7.4.1 Description and graphical results
7.4.2 Matlab script
7.5 Triprotic acid and sodium salt: H3PO4 + Na3PO4
7.5.1 Description and results
7.5.2 Matlab script
7.6 Titration of a triprotic acid with addition of NaOH
7.6.1 Description and graphical results
7.6.2 Matlab script
7.7 Carbonatic acid–base equilibria involving the precipitation of CaCO3 and Mg(OH)2
7.7.1 Description and numerical results
7.7.2 Matlab script
7.8 Pure water electric conductivity at different temperatures
7.8.1 Description and graphical results
7.8.2 Matlab script
7.9 pH and water ionic product from 0°C to 80°C
Reference
8 Colligative properties of solutions aided by Matlab
8.1 Aqueous solutions of NaCl
8.1.1 Description
8.1.2 Matlab script
8.1.3 Output in command window
8.2 Density of aqueous solutions: linear regression
8.2.1 The regression of density data in terms of temperature and concentration
8.2.2 Numerical results of the regression
8.2.3 Analysis of variance
8.2.4 Graphical analysis
8.2.5 Matlab script
References
9 Exploring seawater chemical equilibria with Matlab
9.1 Introduction
9.2 Why seawater reacts with atmospheric CO2?
9.3 Methods and techniques for dealing with seawater chemistry
9.4 Surface chemistry
9.4.1 Description and graphical results
9.4.2 Matlab script
9.5 Ocean chemistry under pressure up to 100MPa
9.5.1 Different pH scales in ocean chemistry
9.5.2 Heterogeneous reactions in ocean chemistry
9.5.3 Hydrostatic pressure acting on homogeneous and heterogeneous equilibria
9.5.4 Ocean chemistry in a broad perspective
9.5.5 Matlab script
9.5.6 The sea water equilibria computation
9.5.7 The electro-neutrality function
9.5.8 The graphical script
9.5.9 Typical numerical and graphical results
9.6 Phosphate chemistry in seawater
9.6.1 Description and graphical results
9.6.2 Matlab script
9.7 Density of seawater versus salinity, temperature, and pressure
9.7.1 Description
9.7.2 Matlab script
References
10 Prevalence diagrams for common elements aided by Matlab
10.1 Introduction and scope
10.2 The electrode potential E0 and the galvanic cell
10.3 Energy analysis of a galvanic cell
10.3.1 Introduction
10.3.2 Example 1
10.4 The Nernst equation
10.4.1 Introduction
10.4.2 Example 2
10.4.3 Example 3
10.5 The electron activity
10.6 The prevalence (or Pourbaix) diagrams
10.6.1 Introduction
10.6.2 Two alternative algorithms for building prevalence/stability diagrams
10.7 The first algorithm
10.8 The second algorithm
10.8.1 The main script
10.8.2 The functions
10.9 The fundamental prevalence diagram: water
10.9.1 Description
10.9.2 Graphical and numerical results
10.10 Manganese oxides and hydroxides
10.10.1 Description, graphical, and numerical results
10.11 Lead and lead sulfate
10.11.1 Description
10.12 Sulfur
10.12.1 Description, numerical, and graphical results
10.13 Au/Cl in seawater
10.13.1 Description
10.13.2 Graphical and numerical results
References
Appendix A Linear algebra
A.1 Bases of a vector space
A.1.1 Vectors, matrices, and bases
A.1.2 Rank of a matrix
A.2 Orthogonal bases
A.3 Eigenvalues and eigenvectors
Reference
Appendix B Introduction to dynamic systems
B.1 State space equations: generalities
B.2 Linear time invariant equations
B.2.1 Generalities
B.2.2 Examples of linear time invariant dynamic systems
B.3 Perturbation equations and local stability of nonlinear systems
B.3.1 Perturbation equations
B.3.2 Second-order equilibrium points
B.3.3 Lyapunov exponents
B.3.4 Singular perturbation
References
Appendix C Introduction to linear regression
C.1 Model and measurement errors
C.2 Linear regression and least squares estimation
C.3 Model degrees of freedom and test of significance
C.3.1 Overfitting and poor fitting
C.3.2 Student’s t-test
C.3.3 F-test
C.3.4 p-value
References
Appendix D Introduction to Matlab Simulink
D.1 Simulink pane and library
D.2 The integrator block
D.3 The configuration parameters
D.4 The script and graphical output
D.5 Initialization script
D.6 View of a 3D graphical plot
D.7 Matlab ODE solvers
D.7.1 Principles of ODE solvers
D.7.2 Matlab solver comparison
Reference
Appendix E Table of seawater coefficients
E.1 The printout script
E.2 Numerical tables
E.2.1 Standard salinity concentrations and electrical charge
E.2.2 Coefficients of carbonatic species
E.2.3 Other species
E.2.4 Fugacity and H2O vapor pressure
Reference
Appendix F The Schroedinger equation
F.1 Introduction
F.1.1 Time-dependent equation
F.1.2 Derivation
F.1.3 Time-independent equation
F.2 Solution of the stationary equation
F.2.1 Passing to spherical coordinates
F.3 Angular waves
F.3.1 Variable separation
F.3.2 Azimuth equation
F.3.3 Polar angle equation
F.4 Radial function of the hydrogen atom
Reference
Index
Back Cover