ChemistryFormulaManager.ipynb

In [1]:
from xv.chemistry.physical import ChemistryFormulaManager
In [2]:
ke = ChemistryFormulaManager(verbose = False)
ke
Out[2]:
2621109028368@ChemistryFormulaManager

Principle of proportionality


Minimum Grade: 4
Maximum Grade: 10


Examples
--------
ke = ChemistryFormulaManager()
ke

ke.printProblemTypes()
ke.helpProblemType(0)

ke.getRandomProblem()
ke.getRandomProblem(problem_type = 0)
ke.getRandomProblem(problem_type = 0, search = 'gas')


ke.printProblem()
ke.printAnswer()
ke.printSolution()


doc_style: xv_doc

In [3]:
ke.printProblemTypes()
0. _problem_search_units_in_chemistry
1. _problem_compatible_units
2. _problem_dimension_of_constant
3. _problem_physical_constants
4. _problem_convert_units
5. _problem_random_proportional_relation
6. _problem_random_proportional_computation
In [ ]:
 
In [4]:
from IPython.display import HTML
n = len(ke._problemTemplates)
max_loop = 1
for j in range(0, max_loop):
    for i in range(n):
        problem_type = i
        display(HTML(f"<h2>problem_type: {problem_type}/{n-1} (loop {j}/{max_loop-1})</h2>"))
        ke.getRandomProblem(problem_type = problem_type, verbose = True)
        display(ke.printProblem())

        display(HTML(f"<h6>Answer:</h6>"))
        display(ke.printAnswer())

        display(HTML(f"<h6>Solution:</h6>"))
        display(ke.printSolution())
        pass

problem_type: 0/6 (loop 0/0)

Problem Template: _problem_search_units_in_chemistry
Write details of unit imperial_gallon.
Answer:

imperial_gallon


dimensionality: [length] ** 3

base units: 0.004546090000000002 meter ** 3

dimensionless: False

Compatible units of imperial_gallon


  • cubic_centimeter
  • stere
  • lambda
  • liter
Solution:

imperial_gallon


dimensionality: [length] ** 3

base units: 0.004546090000000002 meter ** 3

dimensionless: False

Compatible units of imperial_gallon


  • cubic_centimeter
  • stere
  • lambda
  • liter

Notes:


To get all unit names:
ke.ps.unit_names

problem_type: 1/6 (loop 0/0)

Problem Template: _problem_compatible_units
Write compatible units of weber.
Answer:
Compatible units of weber:

unit_pole = $\displaystyle 1.2566370621250598e-07 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

magnetic_flux_quantum = $\displaystyle 2.0678338484619295e-15 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

weber = $\displaystyle 1.0 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$
Solution:
Compatible units of weber:

unit_pole = $\displaystyle 1.2566370621250598e-07 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

magnetic_flux_quantum = $\displaystyle 2.0678338484619295e-15 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

weber = $\displaystyle 1.0 \; \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

problem_type: 2/6 (loop 0/0)

Problem Template: _problem_dimension_of_constant
What is dimension and base unit of tansec?
Answer:
tansec = dimensionless
Solution:
tansec = dimensionless

problem_type: 3/6 (loop 0/0)

Problem Template: _problem_physical_constants
Details of some of important physical constants.
Answer:
K alpha Cu d 220 = 0.80232719 $\displaystyle dimensionless$

K alpha Mo d 220 = 0.36940604 $\displaystyle dimensionless$

K alpha W d 220 = 0.108852175 $\displaystyle dimensionless$

atomic mass constant = 1.6605390666e-27 $\displaystyle kilogram$

avogadro constant = 6.02214076e+23 $\displaystyle \frac{1}{mole}$

avogadro number = 6.02214076e+23 $\displaystyle dimensionless$

boltzmann constant = 1.380649e-23 $\displaystyle \frac{kilogram\;meter^{2}}{kelvin\;second^{2}}$

classical electron radius = 2.817940326216153e-15 $\displaystyle meter$

conductance quantum = 7.74809172986365e-05 $\displaystyle \frac{ampere^{2}\;second^{3}}{kilogram\;meter^{2}}$

conventional josephson constant = 483597900000000.0 $\displaystyle \frac{ampere\;second^{2}}{kilogram\;meter^{2}}$

conventional von klitzing constant = 25812.807 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

coulomb constant = 8987551792.29697 $\displaystyle \frac{kilogram\;meter^{3}}{ampere^{2}\;second^{4}}$

dirac constant = 1.0545718176461565e-34 $\displaystyle \frac{kilogram\;meter^{2}}{second}$

electron g factor = -2.00231930436256 $\displaystyle dimensionless$

electron mass = 9.1093837015e-31 $\displaystyle kilogram$

elementary charge = 1.602176634e-19 $\displaystyle ampere\;second$

eulers number = 2.718281828459045 $\displaystyle dimensionless$

faraday constant = 96485.33212331001 $\displaystyle \frac{ampere\;second}{mole}$

fine structure constant = 0.007297352569307099 $\displaystyle dimensionless$

first radiation constant = 3.7417718521927573e-16 $\displaystyle \frac{kilogram\;meter^{4}}{second^{3}}$

impedance of free space = 376.73031366837046 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

josephson constant = 483597848416983.56 $\displaystyle \frac{ampere\;second^{2}}{kilogram\;meter^{2}}$

lattice spacing of Si = 1.920155716e-10 $\displaystyle meter$

ln10 = 2.302585092994046 $\displaystyle dimensionless$

magnetic flux quantum = 2.0678338484619295e-15 $\displaystyle \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

molar gas constant = 8.314462618153241 $\displaystyle \frac{kilogram\;meter^{2}}{kelvin\;mole\;second^{2}}$

neutron mass = 1.67492749804e-27 $\displaystyle kilogram$

newtonian constant of gravitation = 6.6743e-11 $\displaystyle \frac{meter^{3}}{kilogram\;second^{2}}$

pi = 3.141592653589793 $\displaystyle dimensionless$

planck constant = 6.626070150000001e-34 $\displaystyle \frac{kilogram\;meter^{2}}{second}$

proton mass = 1.67262192369e-27 $\displaystyle kilogram$

rydberg constant = 10973731.56816 $\displaystyle \frac{1}{meter}$

second radiation constant = 0.014387768775039339 $\displaystyle kelvin\;meter$

speed of light = 299792458.0 $\displaystyle \frac{meter}{second}$

standard atmosphere = 101325.0 $\displaystyle \frac{kilogram}{meter\;second^{2}}$

standard gravity = 9.80665 $\displaystyle \frac{meter}{second^{2}}$

stefan boltzmann constant = 5.670374419184431e-08 $\displaystyle \frac{kilogram}{kelvin^{4}\;second^{3}}$

tansec = 4.848136811133344e-06 $\displaystyle dimensionless$

thomson cross section = 6.652458732226516e-29 $\displaystyle meter^{2}$

vacuum permeability = 1.2566370621250601e-06 $\displaystyle \frac{kilogram\;meter}{ampere^{2}\;second^{2}}$

vacuum permittivity = 8.854187812764727e-12 $\displaystyle \frac{ampere^{2}\;second^{4}}{kilogram\;meter^{3}}$

von klitzing constant = 25812.807459304513 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

wien frequency displacement law constant = 58789257576.46826 $\displaystyle \frac{1}{kelvin\;second}$

wien u = 2.8214393721220787 $\displaystyle dimensionless$

wien wavelength displacement law constant = 0.002897771955185173 $\displaystyle kelvin\;meter$

wien x = 4.965114231744276 $\displaystyle dimensionless$

zeta = 29979245800.0 $\displaystyle dimensionless$
Solution:
K alpha Cu d 220 = 0.80232719 $\displaystyle dimensionless$

K alpha Mo d 220 = 0.36940604 $\displaystyle dimensionless$

K alpha W d 220 = 0.108852175 $\displaystyle dimensionless$

atomic mass constant = 1.6605390666e-27 $\displaystyle kilogram$

avogadro constant = 6.02214076e+23 $\displaystyle \frac{1}{mole}$

avogadro number = 6.02214076e+23 $\displaystyle dimensionless$

boltzmann constant = 1.380649e-23 $\displaystyle \frac{kilogram\;meter^{2}}{kelvin\;second^{2}}$

classical electron radius = 2.817940326216153e-15 $\displaystyle meter$

conductance quantum = 7.74809172986365e-05 $\displaystyle \frac{ampere^{2}\;second^{3}}{kilogram\;meter^{2}}$

conventional josephson constant = 483597900000000.0 $\displaystyle \frac{ampere\;second^{2}}{kilogram\;meter^{2}}$

conventional von klitzing constant = 25812.807 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

coulomb constant = 8987551792.29697 $\displaystyle \frac{kilogram\;meter^{3}}{ampere^{2}\;second^{4}}$

dirac constant = 1.0545718176461565e-34 $\displaystyle \frac{kilogram\;meter^{2}}{second}$

electron g factor = -2.00231930436256 $\displaystyle dimensionless$

electron mass = 9.1093837015e-31 $\displaystyle kilogram$

elementary charge = 1.602176634e-19 $\displaystyle ampere\;second$

eulers number = 2.718281828459045 $\displaystyle dimensionless$

faraday constant = 96485.33212331001 $\displaystyle \frac{ampere\;second}{mole}$

fine structure constant = 0.007297352569307099 $\displaystyle dimensionless$

first radiation constant = 3.7417718521927573e-16 $\displaystyle \frac{kilogram\;meter^{4}}{second^{3}}$

impedance of free space = 376.73031366837046 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

josephson constant = 483597848416983.56 $\displaystyle \frac{ampere\;second^{2}}{kilogram\;meter^{2}}$

lattice spacing of Si = 1.920155716e-10 $\displaystyle meter$

ln10 = 2.302585092994046 $\displaystyle dimensionless$

magnetic flux quantum = 2.0678338484619295e-15 $\displaystyle \frac{kilogram\;meter^{2}}{ampere\;second^{2}}$

molar gas constant = 8.314462618153241 $\displaystyle \frac{kilogram\;meter^{2}}{kelvin\;mole\;second^{2}}$

neutron mass = 1.67492749804e-27 $\displaystyle kilogram$

newtonian constant of gravitation = 6.6743e-11 $\displaystyle \frac{meter^{3}}{kilogram\;second^{2}}$

pi = 3.141592653589793 $\displaystyle dimensionless$

planck constant = 6.626070150000001e-34 $\displaystyle \frac{kilogram\;meter^{2}}{second}$

proton mass = 1.67262192369e-27 $\displaystyle kilogram$

rydberg constant = 10973731.56816 $\displaystyle \frac{1}{meter}$

second radiation constant = 0.014387768775039339 $\displaystyle kelvin\;meter$

speed of light = 299792458.0 $\displaystyle \frac{meter}{second}$

standard atmosphere = 101325.0 $\displaystyle \frac{kilogram}{meter\;second^{2}}$

standard gravity = 9.80665 $\displaystyle \frac{meter}{second^{2}}$

stefan boltzmann constant = 5.670374419184431e-08 $\displaystyle \frac{kilogram}{kelvin^{4}\;second^{3}}$

tansec = 4.848136811133344e-06 $\displaystyle dimensionless$

thomson cross section = 6.652458732226516e-29 $\displaystyle meter^{2}$

vacuum permeability = 1.2566370621250601e-06 $\displaystyle \frac{kilogram\;meter}{ampere^{2}\;second^{2}}$

vacuum permittivity = 8.854187812764727e-12 $\displaystyle \frac{ampere^{2}\;second^{4}}{kilogram\;meter^{3}}$

von klitzing constant = 25812.807459304513 $\displaystyle \frac{kilogram\;meter^{2}}{ampere^{2}\;second^{3}}$

wien frequency displacement law constant = 58789257576.46826 $\displaystyle \frac{1}{kelvin\;second}$

wien u = 2.8214393721220787 $\displaystyle dimensionless$

wien wavelength displacement law constant = 0.002897771955185173 $\displaystyle kelvin\;meter$

wien x = 4.965114231744276 $\displaystyle dimensionless$

zeta = 29979245800.0 $\displaystyle dimensionless$

To get names of all compatible units:
ke.ps.get_compatible_units(unit_name)

problem_type: 4/6 (loop 0/0)

Problem Template: _problem_convert_units

Convert 2 short-ton to metric-ton.

Note: You may use the following table:
1 ounce     =     28.35 gram
1 pound     =     16 oz
1 kilo-gram     =     2.205 pound
1 pound     =     0.0005 short-ton
1 metric-ton     =     1.12 short-ton
1 long-ton     =     1.016 metric-ton
1 grain     =     0.05 scruple
1 grain     =     0.01667 dram
1 grain     =     0.00208 ounce
1 kilo-gram     =     1000 gram
Answer:
1.7857142857142856 metric-ton
Solution:

2 short-ton = ? metric-ton
2022-10-01T20:15:47.449430 image/svg+xml Matplotlib v3.5.3, https://matplotlib.org/

The conversion path will be:
short-ton→metric-ton

2 short-ton

= 2 short-ton * $ { \frac { 1\;metric\;ton } { 1.12\;short\;ton } } $


= 2 * $ { \frac { 1 } { 1.12 } } $ metric-ton


= 2 * 0.8928571428571428 metric-ton

= 1.7857142857142856 metric-ton

problem_type: 5/6 (loop 0/0)

Problem Template: _problem_random_proportional_relation

Van der waals gases



Van der waals gases
Express $V$ as a function of $n$, $P$, $T$

$V$ = Volume of ideal gas
$n$ = Number of moles of ideal gas
$P$ = External pressure on of ideal gas
$T$ = Temperature of ideal gas
$R$ = Ideal Gas Constant
$a$ = A is a constant whose value depends on the gas
$b$ = The volume that is occupied by one mole of the molecules

Use constant = $\displaystyle R$
Answer:
$\displaystyle V - n 1 \propto \frac{T V^{2} n}{P V^{2} + n^{2}}$

$\displaystyle \implies V - n b = R T n \left(P + \frac{n^{2} a}{V^{2}}\right)^{-1}$

$\displaystyle \implies \left(P + \frac{n^{2} a}{V^{2}}\right) \left(V - n b\right) = n R T$
Solution:
Let:

$V$ = Volume of ideal gas
$n$ = Number of moles of ideal gas
$P$ = External pressure on of ideal gas
$T$ = Temperature of ideal gas
$R$ = Ideal Gas Constant
$a$ = A is a constant whose value depends on the gas
$b$ = The volume that is occupied by one mole of the molecules

The relation between variables:

$\displaystyle V - n 1 \propto \frac{V^{2} n}{V^{2} + n^{2}}$

$\displaystyle V - 1^{2} \propto \frac{V^{2}}{P V^{2} + 1}$

$\displaystyle V - 1^{2} \propto \frac{T V^{2}}{V^{2} + 1}$

$\displaystyle \implies V - n 1 \propto \frac{T V^{2} n}{P V^{2} + n^{2}}$

$\displaystyle
\implies V - n b = R T n \left(P + \frac{n^{2} a}{V^{2}}\right)^{-1}
\qquad \text{as constant} = R
$

problem_type: 6/6 (loop 0/0)

E:\eclipse\python\xv-km-lib\src\xv\km\_sympy_extension\extended\_extend_Eq.py:312: SymPyDeprecationWarning: 

The string fallback in sympify() is deprecated.

To explicitly convert the string form of an object, use
sympify(str(obj)). To add define sympify behavior on custom
objects, use sympy.core.sympify.converter or define obj._sympy_
(see the sympify() docstring).

sympify() performed the string fallback resulting in the following string:

'gram'

See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-sympify-string-fallback
for details.

This has been deprecated since SymPy version 1.6. It
will be removed in a future version of SymPy.

  physical_unit_str = latex(sympify(physical_unit)).replace(" ", "\\;")
E:\eclipse\python\xv-km-lib\src\xv\km\_sympy_extension\extended\_extend_Eq.py:312: SymPyDeprecationWarning: 

The string fallback in sympify() is deprecated.

To explicitly convert the string form of an object, use
sympify(str(obj)). To add define sympify behavior on custom
objects, use sympy.core.sympify.converter or define obj._sympy_
(see the sympify() docstring).

sympify() performed the string fallback resulting in the following string:

'gram / mole'

See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-sympify-string-fallback
for details.

This has been deprecated since SymPy version 1.6. It
will be removed in a future version of SymPy.

  physical_unit_str = latex(sympify(physical_unit)).replace(" ", "\\;")
E:\eclipse\python\xv-km-lib\src\xv\km\_sympy_extension\extended\_extend_Eq.py:312: SymPyDeprecationWarning: 

The string fallback in sympify() is deprecated.

To explicitly convert the string form of an object, use
sympify(str(obj)). To add define sympify behavior on custom
objects, use sympy.core.sympify.converter or define obj._sympy_
(see the sympify() docstring).

sympify() performed the string fallback resulting in the following string:

'mole'

See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-sympify-string-fallback
for details.

This has been deprecated since SymPy version 1.6. It
will be removed in a future version of SymPy.

  physical_unit_str = latex(sympify(physical_unit)).replace(" ", "\\;")
E:\eclipse\python\xv-km-lib\src\xv\km\_sympy_extension\extended\_extend_Eq.py:312: SymPyDeprecationWarning: 

The string fallback in sympify() is deprecated.

To explicitly convert the string form of an object, use
sympify(str(obj)). To add define sympify behavior on custom
objects, use sympy.core.sympify.converter or define obj._sympy_
(see the sympify() docstring).

sympify() performed the string fallback resulting in the following string:

'AMU / gram'

See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-sympify-string-fallback
for details.

This has been deprecated since SymPy version 1.6. It
will be removed in a future version of SymPy.

  physical_unit_str = latex(sympify(physical_unit)).replace(" ", "\\;")
E:\eclipse\python\xv-km-lib\src\xv\km\_sympy_extension\extended\_extend_Eq.py:312: SymPyDeprecationWarning: 

The string fallback in sympify() is deprecated.

To explicitly convert the string form of an object, use
sympify(str(obj)). To add define sympify behavior on custom
objects, use sympy.core.sympify.converter or define obj._sympy_
(see the sympify() docstring).

sympify() performed the string fallback resulting in the following string:

'AMU'

See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-sympify-string-fallback
for details.

This has been deprecated since SymPy version 1.6. It
will be removed in a future version of SymPy.

  physical_unit_str = latex(sympify(physical_unit)).replace(" ", "\\;")
Problem Template: _problem_random_proportional_computation

Gram AMU Conversion



Find $n$

Where:

$\displaystyle
m $ = mass of Neodymium atom in gram = $\displaystyle
2884.84000000000 \; gram $

$\displaystyle
M $ = Mass of one mole of Neodymium atom = $\displaystyle
144.242000000000 \; \frac{gram}{mole} $

$\displaystyle
n $ = Number of moles of Neodymium atom ($\frac{m}{M}$)

$\displaystyle
N $ = atomic mass unit (AMU) per gram = $\displaystyle
6.02214076e+23 \; \frac{AMU}{gram} $

$\displaystyle
q $ = mass of Neodymium atom in atomic mass unit (AMU) = $\displaystyle
1.73729125500784E+27 \; AMU $
Answer:
$\displaystyle 20.0\;mole$
Solution:
Let:

$q$ = mass of Neodymium atom in atomic mass unit (AMU)
$m$ = mass of Neodymium atom in gram
$M$ = Mass of one mole of Neodymium atom
$n$ = Number of moles of Neodymium atom ($\frac{m}{M}$)
$N$ = atomic mass unit (AMU) per gram

The relation between variables:

$\displaystyle q \propto n$

$\displaystyle q \propto M$

$\displaystyle \implies q \propto M n$

$\displaystyle
\implies q = N M n
\qquad \text{as constant} = N
$

Substituting values:

$\displaystyle \implies \left(1.73729125500784E+27\;AMU\right) = \left(6.02214076e+23\;\frac{AMU}{gram}\right) \left(144.242000000000\;\frac{gram}{mole}\right) n$

Hint:

Molar mass of Neodymium atom
= 144.242 $\mathtt{\text{AMU}}$
= 144.242000000000 $\mathtt{\text{AMU}}$

Simplify the equation:

$\displaystyle \implies 1.73729125500784\;\cdot\;10^{27}\;AMU\;=\;\frac{8.6864562750392\;\cdot\;10^{25}\;AMU\;n}{mole}$

Solve for $n$:

$\displaystyle \implies n =
$ $\displaystyle 20.0\;mole$
In [ ]:
 

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing