Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

# coding: utf-8 

# Copyright (c) Pymatgen Development Team. 

# Distributed under the terms of the MIT License. 

 

from __future__ import division, unicode_literals 

 

""" 

A module to perform experimental thermochemical data analysis. 

""" 

 

 

__author__ = "Shyue Ping Ong" 

__copyright__ = "Copyright 2012, The Materials Project" 

__version__ = "0.1" 

__maintainer__ = "Shyue Ping Ong" 

__email__ = "shyuep@gmail.com" 

__date__ = "Jun 10, 2012" 

 

 

from pymatgen.core.composition import Composition 

 

 

STANDARD_TEMP = 298.0 

 

 

class ThermoData(object): 

""" 

A object container for an experimental Thermochemical Data. 

 

Args: 

data_type: The thermochemical data type. Should be one of the 

following: fH - Formation enthalpy, S - Entropy, 

A, B, C, D, E, F, G, H - variables for use in the various 

quations for generating formation enthaplies or Cp at 

various temperatures. 

cpdname (str): A name for the compound. For example, hematite for 

Fe2O3. 

phaseinfo (str): Denoting the phase. For example, "solid", "liquid", 

"gas" or "tetragonal". 

formula (str): A proper string formula, e.g., Fe2O3 

value (float): The value of the data. 

ref (str): A reference, if any, for the data. 

method (str): The method by which the data was determined, 

if available. 

temp_range ([float, float]): Temperature range of validity for the 

data in Kelvin. Defaults to 298 K only. 

uncertainty (float): 

An uncertainty for the data, if available. 

""" 

def __init__(self, data_type, cpdname, phaseinfo, formula, value, ref="", 

method="", temp_range=(298, 298), uncertainty=None): 

self.type = data_type 

self.formula = formula 

self.composition = Composition(self.formula) 

self.reduced_formula = self.composition.reduced_formula 

self.compound_name = cpdname 

self.phaseinfo = phaseinfo 

self.value = value 

self.temp_range = temp_range 

self.method = method 

self.ref = ref 

self.uncertainty = uncertainty 

 

@classmethod 

def from_dict(cls, d): 

return ThermoData(d["type"], d["compound_name"], 

d["phaseinfo"], d["formula"], 

d["value"], d["ref"], d["method"], 

d["temp_range"], d.get("uncertainty", None)) 

 

def as_dict(self): 

return {"@module": self.__class__.__module__, 

"@class": self.__class__.__name__, "type": self.type, 

"formula": self.formula, "compound_name": self.compound_name, 

"phaseinfo": self.phaseinfo, "value": self.value, 

"temp_range": self.temp_range, "method": self.method, 

"ref": self.ref, "uncertainty": self.uncertainty} 

 

def __repr__(self): 

props = ["formula", "compound_name", "phaseinfo", "type", "temp_range", 

"value", "method", "ref", "uncertainty"] 

output = ["{} : {}".format(k, getattr(self, k)) for k in props] 

return "\n".join(output) 

 

def __str__(self): 

return "{}_{}_{} = {}, Valid T : {}, Ref = {}".format( 

self.type, self.formula, self.phaseinfo, self.value, 

self.temp_range, self.ref 

)