Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lordkman/burnman into Pla…
Browse files Browse the repository at this point in the history
…nets
  • Loading branch information
CaymanUnterborn committed Dec 13, 2015
2 parents b127871 + 288d64f commit d2b7fc2
Show file tree
Hide file tree
Showing 110 changed files with 2,931 additions and 1,433 deletions.
12 changes: 6 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ian.rose@berkeley.edu

## Requirements

* Python 2.7 (not Python 3.x)
* Python 2.7.x or Python 3.4+
* Python modules:
NumPy, SciPy, Matplotlib

Expand All @@ -44,8 +44,8 @@ Figures should show up, indicating that it is working.

1. get Xcode
2. If you don't have Python yet, download it (for free) from
python.org/download . Make sure to use the latest version 2.x version (I
used 2.7). To check your version of python, type the following in a
python.org/download . Make sure to use either Python 2.7 or Python 3.4+.
To check your version of python, type the following in a
terminal:
python --version
3. Install the latest Numpy version: http://sourceforge.net/projects/numpy/files/NumPy/
Expand All @@ -72,7 +72,7 @@ python

## Install under Windows

make Python 2.7.3 (for example) running under windows (do not use Python 3.x, but 2.7.x):
To get Python 2.7.x (for example) running under Windows:

1. Download Python from http://www.python.org/ and install the version at C:\Python27\; the 32-bit version is recommended
2. Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy, download "numpy-MKL-1.6.2.win32-py2.7.exe" and install
Expand Down Expand Up @@ -106,13 +106,13 @@ possible as well as each of the helpers involved with each example.
Burnman has the advantage of being adaptable and extendable in easy scripts. The downside might be that we do not
provide a graphical user interface. For those of you who are not familiar with python, we suspect it will still be
relatively easy to adapt the scripts for computations and plotting.
Here are some specific features and pitfalls on python:
Here are some specific features and pitfalls on Python:

* Python uses specific identation. A script might fail if a code block is not idented correctly. We use four spaces and no tabs,
mixing these can give trouble.
* Indices require square brackets and function or method calls parentheses (mainly different from Matlab).
* The first index of an array is 0 (e.g. x[0])
* Put dots after numbers to make them floats instead of integers (e.g. 5/3 will give 1 (rounded downward), while 5./3. will give 1.66666666667)
* Put dots after numbers to make them floats instead of integers (e.g. 5/3 will give 1 (Python 2.x rounds downward), while 5./3. will give 1.66666666667)


## Examples
Expand Down
39 changes: 20 additions & 19 deletions burnman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,35 @@
Bill McDonough, Quentin Williams, Wendy Panero, and Wolfgang Bangerth.
"""
from __future__ import absolute_import

from version import version as __version__
from .version import version as __version__

# classes for representing rocks and minerals:
from mineral import Mineral
from material import Material
from composite import Composite
from solutionmodel import SolutionModel
from solidsolution import SolidSolution
from mineral_helpers import *
from .mineral import Mineral
from .material import Material
from .composite import Composite
from .solutionmodel import SolutionModel
from .solidsolution import SolidSolution
from .mineral_helpers import *

# high level functions
from main import *
from model import Model
from .main import *
from .model import Model

# mineral library
import minerals
from . import minerals

# central user tools
import seismic
import averaging_schemes
import eos
from . import seismic
from . import averaging_schemes
from . import eos

import processchemistry
import chemicalpotentials
from solutionmodel import SolutionModel
import geotherm
from . import processchemistry
from . import chemicalpotentials
from .solutionmodel import SolutionModel
from . import geotherm

# miscellaneous
import tools
from partitioning import calculate_partition_coefficient,calculate_phase_percents
from . import tools
from .partitioning import calculate_partition_coefficient,calculate_phase_percents
25 changes: 10 additions & 15 deletions burnman/averaging_schemes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences
# Copyright (C) 2012 - 2015 by the BurnMan team, released under the GNU GPL v2 or later.


from __future__ import absolute_import
import numpy as np
import warnings

Expand Down Expand Up @@ -64,8 +64,7 @@ def average_shear_moduli(self, volumes, bulk_moduli, shear_moduli):
def average_density(self, volumes, densities):
"""
Average the densities of a composite, given a list of volume
fractions and densitites. This is the only method of
:class:`burnman.averaging_schemes.AveragingScheme` which is implemented in the base class,
fractions and densitites. This is implemented in the base class,
as how to calculate it is not dependent on the geometry of the rock.
The formula for density is given by
Expand Down Expand Up @@ -559,10 +558,8 @@ def voigt_average_function(phase_volume, X):
voigt_reuss_hill classes, takes a list of
volumes and moduli, returns a modulus.
"""
it = range(len(phase_volume))
V_i = phase_volume
V_tot = sum(V_i)
X_voigt = sum(V_i[i]/V_tot * X[i] for i in it)
vol_frac = phase_volume/np.sum(phase_volume)
X_voigt = sum( f*x for f,x in zip(vol_frac, X))
return X_voigt


Expand All @@ -573,14 +570,12 @@ def reuss_average_function(phase_volume, X):
voigt_reuss_hill classes, takes a list of
volumes and moduli, returns a modulus.
"""
it = range(len(phase_volume))
V_i = phase_volume
V_tot = sum(V_i)
if (min(X)<=0.0):
X_reuss = 0.0
warnings.warn("Oops, called reuss_average with Xi<=0!")
else:
X_reuss = 1./sum(V_i[i]/V_tot* 1./X[i] for i in it)
vol_frac = phase_volume/np.sum(phase_volume)
for f,x in zip(vol_frac,X):
if x <= 0 and np.abs(f) > np.finfo(float).eps :
warnings.warn("Oops, called reuss_average with Xi<=0!")
return 0.0
X_reuss = 1./sum( f/x for f,x in zip(vol_frac, X))
return X_reuss


Expand Down
11 changes: 5 additions & 6 deletions burnman/chemicalpotentials.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences
# Copyright (C) 2012 - 2015 by the BurnMan team, released under the GNU GPL v2 or later.


from __future__ import absolute_import
import numpy as np
from scipy.linalg import lu

import burnman
from burnman import minerals
from processchemistry import *
import burnman.constants as constants
from .processchemistry import *
from . import constants
from . import solidsolution

# This module computes chemical potentials (partial molar gibbs free energies) for an assemblage based on the Gibbs free energies and compositions of the individual phases.

Expand Down Expand Up @@ -48,7 +47,7 @@ def chemical_potentials(assemblage, component_formulae):
endmember_list=[]
endmember_potentials=[]
for mineral in assemblage:
if isinstance(mineral, burnman.SolidSolution):
if isinstance(mineral, solidsolution.SolidSolution):
for member in mineral.endmembers:
endmember_list.append(member[0])
for potential in mineral.partial_gibbs:
Expand Down

0 comments on commit d2b7fc2

Please sign in to comment.