Initial commit

This commit is contained in:
2019-02-03 23:32:39 +01:00
commit 11db5afc2f
3 changed files with 305 additions and 0 deletions

44
data/INFO.json Normal file
View File

@@ -0,0 +1,44 @@
{
"Name": "Name of the material",
"Formula": "Formula of the material",
"CAS Reg No.": "Chemical Abstracts Service Registry Number",
"Mol. weight": "Molecular weight (relative molar mass)",
"Physical Form": "Physical form of material",
"Equilibrium": {
"p": "pressure",
"rho": "Density at pressure p and temperature T",
"T": "Temperature",
"Tm": "Normal melting point at pressure p",
"Tb": "Normal boiling point at vapor pressure p",
},
"rho(T)": "Estimated density at higher temperatures (up to Tmax or about 20°C): \\[\rho(T)=\rho\ti{m}-k(T-T_m)\]",
"p_b(T)": "Vapor pressure \(p\) in pascals: \[\log(p/Pa) = 5.006 + A + BT^{-1} + C\log{T} + DT^3\] where temperature T in K; p. 6-72",
"Electromagnetic Data": {
"chi_m": "p. 4-142. Magnetic susceptibility; Molar susceptibility \[\chi\ti{m} = \kappa V\ti{m} = \kappa M / \rho \] where \(\kappa\) is the volume susceptibility, \(V\ti{m}\) is the molar volume of the substance, \(M\) the molar mass, and \(\rho\) the mass density. \(\kappa = \bold{M}/\bold{H}\) where \(\bold{H}\) is the magnetic filed and \(\bold{M}\) is magnetic moment per unit volume.",
},
"Thermodynamic Properties": {
"Delta_f H°": "Standard molar enthalpy (heat) of formation at 298.15 K in kj/mol. 0.0 indicates the reference state.",
"Delta_f G°": "Standard molar Gibbs energy of formation at 298.15 K in kJ/mol",
"S°": "Standard molar entropy at 298.15 K in J/mol K",
"cp": "Specific heat capacity",
"Cp": "Molar heat capacity at constant pressure at 298.15 K in J/mol K",
"Delta_vap H": "Molar enthalpy (heat) of vaporization. Values are given at a pressure of 101.325 kPa",
"Delta_fus H": "Molar enthalpy (heat) of fusion. Values are given at the normal melting point Tm"
},
"Crystallographic Data": {
"Page": "4-156",
"Structure type": "Prototype for the structural arrangement of the crystallographic cell.",
"Z": "Number of formula units per the unit cell.",
"a, b, c": "Length of the cell edges in Å (1 Å = 10e-8 cm)",
"alpha, beta, gamma": "Angles between cell axes"
},
"Human": {
"Constituents of Human Blood": {
"Total volume of blood": "7.5 L for a male and 6.7 L for a female in 100 kg adult.",
"Total volume of plasma": "4.4 L for a male and 4.3 L for a female in 100 kg adult."
},
"Composition of the Human Body": "Standard man = 70 kg"
},
"Borax Beads": "p. 8-13"
}

156
data/aluminum.json Normal file
View File

@@ -0,0 +1,156 @@
[
{
"Name": "Aluminum",
"Formula": "Al",
"CAS Reg No.": "7429-90-5",
"Mol. weight": 26.982,
"Physical Form": "silvery-white metal; cubic crystals",
"Equilibrium": [
{
"p": [1, "Pa"],
"Tb": [1209, "°C"]
},
{
"p": [10, "Pa"],
"Tb": [1359, "°C"]
},
{
"p": [100, "Pa"],
"Tb": [1544, "°C"]
},
{
"p": [1, "kPa"],
"Tb": [1781, "°C"]
},
{
"p": [10, "kPa"],
"Tb": [2091, "°C"]
},
{
"p": [100, "kPa"],
"Tb": [2517, "°C"]
},
{
"p": [101.325, "kPa"],
"rho": [2.70, "g/cm³"],
"T": [25, "°C"],
"Tm": [660.32, "°C"],
"Tb": [2519, "°C"]
}
],
"rho(T)": {
"rho_m": [2.375, "g/cm³"],
"k": [0.000233, "g/cm³ °C"],
"Tmax": [1340, "°C"]
},
"p_b(T)": {
"Solid": {
"A": 9.459,
"B": -17342,
"C": -0.7927,
"D": null,
"Range in K": "298-Tm"
},
"Liquid": {
"A": 5911,
"B": -16211,
"C": null,
"D": null,
"Range in K": "Tm-1800"
}
},
"Electromagnetic Data": {
"chi_m": [16.5e-6, "cm³/mol"]
},
"Thermodynamic Properties": {
"Crystal": {
"Delta_f H°": [0.0, "kJ/mol"],
"Delta_f G°": null,
"S°": [28.3, "J/mol K"],
"cp": [0.897, "J/g K"],
"Cp": [24.20, "J/mol K"]
},
"Liquid": null,
"Gas": {
"Delta_f H°": [330.0, "kJ/mol"],
"Delta_f G°": [289.4, "kJ/mol"],
"S°": [164.6, "J/mol K"],
"Cp": [21.4, "J/mol K"]
},
"Delta_vap H": [
[
[2519, "°C"],
[294, "kJ/mol"]
]
],
"Delta_fus H": [10.71, "kJ/mol"]
},
"Crystallographic Data": {
"Crystal system": "cubic",
"Structure type": "copper",
"Z": 4,
"a": [4.049, "Å"],
"b": null,
"c": null,
"alpha": null,
"beta": null,
"gamma": null
},
"Cubic Crystal": {
"rho": [2.6970, "g/cm³"],
"T": [298, "K"],
"C11": [1.0675e11, "N/m²"],
"C12": [0.6041e11, "N/m²"],
"C44": [0.2834e11, "N/m²"]
},
"Dynamic viscosity mu(T)": [
[
[700, "°C"],
[1.289, "mPa s"]
],
[
[750, "°C"],
[1.200, "mPa s"]
],
[
[800, "°C"],
[1.115, "mPa s"]
],
[
[850, "°C"],
[1.028, "mPa s"]
]
],
"Human": {
"Constituents of Human Blood": {
"Blood sample": "serum",
"Normal Low": [1, "µg/L"],
"Normal High": [10, "µg/L"],
"Critical": [">60", "µg/L"]
},
"Composition of the Human Body": {
"Amount": [0.061, "g"],
"Percent of total body mass": 0.00009
}
},
"Borax Beads": {
"Oxidizing flame": {
"colorless": ["hot", "cold", "not saturated"],
"opaque": "supersaturated"
},
"Reducing flame": {
"colorless": "default",
"opaque": "saturated"
}
},
"Source": {
"Type": "Book",
"Title" : "",
"Pages": [694, 758, 760, 764, 767, 781, 792, 978, 1017, 1035, 1122, 1179, 1182, 1207]
}
},
{
"Name": "G.AL® C250 Aluminium Präzisionsplatte",
"Alloy": ["EN AW 5083", "AlMg4,5Mn0,7", "Sondertyp"]
}
]

105
materials.py Normal file
View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- mode: python-mode; python-indent-offset: 2; tab-width: 2 -*-
"""
Created on Mon Dec 21 19:39:44 2015
@author: Daniel
"""
import sys, os
import argparse
def list():
from os import listdir
for data in listdir("./data"):
file_name = data.split('.')[0]
if file_name != "INFO":
print(file_name)
def read(input, search_keys=None):
import json
from pprint import pprint
def find_values(id, json_repr):
results = []
def _decode_dict(a_dict):
try: results.append(a_dict[id])
except KeyError: pass
return a_dict
json.loads(json_repr, object_hook=_decode_dict) # return value ignored
return results
try:
with open(os.path.join('data', input + '.json')) as data_file:
if search_keys is not None:
data = data_file.read()
for search_key in search_keys:
found_values = find_values(search_key, data)
#print(found_values)
for value in found_values:
#print('%-5s' % value[0] + ' ' + value[1])
print(search_key + ' = ' + '%s' % value[0] + ' ' + value[1])
#def getLength(element):
# try:
# element.__iter__
# return sum([getLength(i) for i in element])
# except:
# return 1
#print(len(data))
#print(getLength(json.loads(data)))
else:
data = json.load(data_file)
pprint(data)
except (OSError, IOError) as err:
print(str(err))
sys.exit(2)
def main():
parser = argparse.ArgumentParser(description='Material database.')
subparsers = parser.add_subparsers(help='commands', dest='command')
# list materials
list_parser = subparsers.add_parser('list',
description='List materials.',
help='list all available materials')
# material
material_parser = subparsers.add_parser('material',
help='the material to get information from')
material_parser.add_argument('materialname', action='store',
help='list available material information')
material_parser.add_argument('-r', '--rho', dest='const_collection',
action='append_const', const="rho",
help='get density from material')
material_parser.add_argument('-T', '--Tm', dest='const_collection',
action='append_const', const="Tm",
help='get melting point temperature')
parser.add_argument('-v', '--version', action='version',
version='%(prog)s 1.0')
args = parser.parse_args()
print(args)
if args.command == 'list':
list()
elif args.command == 'material':
if args.const_collection:
read(args.materialname, search_keys=args.const_collection)
else:
read(args.materialname)
if __name__ == "__main__":
main()