Skip to content

Commit

Permalink
Merge pull request #71 from MineralsCloud/develop
Browse files Browse the repository at this point in the history
Try to solve issue #70 and #47
  • Loading branch information
singularitti authored Jun 16, 2019
2 parents 4ec7fc2 + ca564fe commit 5937c10
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 60 deletions.
36 changes: 25 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
dist: xenial
language: python
os:
- linux
python:
- "3.6"
matrix:
include:
- name: "Python 3.6 on Xenial Linux"
python: 3.6
dist: xenial
- name: "Python 3.7.1 on Xenial Linux"
python: 3.7
dist: xenial
- name: "Python 3.6 on macOS"
os: osx
osx_image: xcode10.1
language: shell
- name: "Python 3.7.2 on macOS"
os: osx
osx_image: xcode10.2 # Python 3.7.2 running on macOS 10.14.3
language: shell # 'language: python' is an error on Travis CI macOS
sudo: required
before_install:
- sudo apt-get install libmpc-dev
install:
- pip install .
- pip install -Iv sphinx==1.7.4
- pip install sphinx-autodoc-typehints
- pip install sphinx_bootstrap_theme
- pip3 install .
- pip3 install -U pytest
- pip3 install -Iv sphinx==1.7.4
- pip3 install sphinx-autodoc-typehints
- pip3 install sphinx_bootstrap_theme
script:
- pytest qha/tests/test_different_phonon_dos.py
- pytest qha/tests/test_read_input.py
- pytest qha/tests/test_single_configuration.py
- pytest qha/tests/test_unit_conversion.py
- cd docs/
- make clean && make html
deploy:
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[TOC]

[![Stable docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://mineralscloud.github.io/qha/)
[![Build Status](https://travis-ci.com/MineralsCloud/qha.svg?branch=master)](https://travis-ci.com/MineralsCloud/qha)

## Contributors

Expand All @@ -25,8 +26,6 @@ please check more details on [Python 3 documentation](https://docs.python.org/3/

To install `qha`, currently, Python 3.6.x distributions are recommended.

Please do not use Python 3.7.x at this moment, since it contains breaking changes and many Python packages don’t support Python 3.7.x yet. We may support Python 3.7.x in the future.

### Where to get it

Binary installers for the latest released version are available at the PyPI.
Expand All @@ -38,7 +37,7 @@ $ pip install qha

### Dependencies

- [bigfloat](https://pypi.python.org/pypi/bigfloat)
- [mpmath](http://mpmath.org/)
- [lazy-property](https://github.com/jackmaney/lazy-property)
- [matplotlib](https://matplotlib.org)
- [Numba](http://numba.pydata.org)
Expand All @@ -57,19 +56,12 @@ The source code is currently hosted on [GitHub](https://github.com/MineralsCloud
$ pip install .
```

Notice that you have to use Python version 3.6.x to install. If you want to install `qha` in development mode, instead run
Notice that you have to use Python version > 3.6.x to install. If you want to install `qha` in development mode, instead run

```shell
$ pip install -e .
```

### Trouble shooting of installation

1. Error raised about `mpfr.h` file: To solve this error, `GMP` and `MPFR` libraries are required to use `bigfloat` package.
* On Linux, install `libmpfr-dev` , for example, on Ubuntu type `apt-get install libmpfr-dev`;
* On Windows, `bigfloat` can be installed from the binary file, please check [“Unofficial Windows Binaries for Python Extension Packages”](https://www.lfd.uci.edu/~gohlke/pythonlibs/), download the version suitable for the system, for example, for a 64-bit system, use pip to install it `pip(3) install /the/path/to/bigfloat‑0.3.0‑cp36‑cp36m‑win_amd64.whl`;
* On macOS, install these libraries via `brew install mpfr`. Of course, you need the [Homebrew package manager](https://brew.sh) installed to run this command.

## Checking the examples

To run the examples, go to `examples/ice VII/` or `examples/silicon/` directories and type in terminal:
Expand Down
12 changes: 1 addition & 11 deletions docs/source/tutorials/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Compatibility
-------------

``qha`` is compatible with Python 3.6.x.
Please do not use Python 3.7.x at this moment, since it contains breaking changes
and many Python packages don’t support Python 3.7.x yet. We may support Python 3.7.x in the future.

Our supported platforms are:

Expand All @@ -22,7 +20,7 @@ Our supported platforms are:

Dependencies
------------
- `bigfloat <https://pypi.python.org/pypi/bigfloat>`_ [#b]_
- `mpmath <http://mpmath.org/>`_
- `lazy-property <https://github.com/jackmaney/lazy-property>`_
- `matplotlib <https://matplotlib.org>`_ [#m]_
- `Numba <http://numba.pydata.org>`_
Expand All @@ -35,14 +33,6 @@ Dependencies

Notes:

.. [#b] ``GMP`` and ``MPFR`` libraries are required to use ``bigfloat`` package. On macOS,
install these libraries via ``brew install mpfr``; on Linux, install ``libmpfr-dev`` ,
for example, on Ubuntu use ``apt-get install libmpfr-dev``;
on Windows, ``bigfloat`` can be installed from the binary file, please check
`Unofficial Windows Binaries for Python Extension Packages <https://www.lfd.uci.edu/~gohlke/pythonlibs/>`_,
download the version suitable for the system, for example,for a 64-bit system,
use pip to install it ``pip(3) install /the/path/to/bigfloat‑0.3.0‑cp36‑cp36m‑win_amd64.whl``;
.. [#m] For some systems, ``python-tkinter`` package is needed by ``matplotlib``, otherwise the plot function will not work.
Installing the ``qha`` package
Expand Down
24 changes: 12 additions & 12 deletions qha/multi_configurations/different_phonon_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ def partition_functions_for_each_configuration(self):
:return: A matrix, the partition function of each configuration of each volume.
"""
try:
import bigfloat
import mpmath
except ImportError:
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))

with bigfloat.precision(self.precision):
with mpmath.workprec(self.precision):
# shape = (# of configurations, # of volumes for each configuration)
exp = np.vectorize(bigfloat.exp)
exp = np.vectorize(mpmath.exp)
return exp(-self.aligned_free_energies_for_each_configuration / (K * self.temperature))

@LazyProperty
Expand All @@ -139,13 +139,13 @@ def partition_functions_for_all_configurations(self):
:return: A vector, the partition function of each volume.
"""
try:
import bigfloat
import mpmath
except ImportError:
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))

with bigfloat.precision(self.precision):
with mpmath.workprec(self.precision):
# shape = (# of volumes,)
return np.array([bigfloat.exp(d) for d in
return np.array([mpmath.exp(d) for d in
logsumexp(-self.aligned_free_energies_for_each_configuration.T / (K * self.temperature),
axis=1, b=self.degeneracies)])

Expand All @@ -160,10 +160,10 @@ def get_free_energies(self):
:return: The free energy on a temperature-volume grid.
"""
try:
import bigfloat
import mpmath
except ImportError:
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))

with bigfloat.precision(self.precision):
log_z = np.array([bigfloat.log(d) for d in self.partition_functions_for_all_configurations], dtype=float)
with mpmath.workprec(self.precision):
log_z = np.array([mpmath.log(d) for d in self.partition_functions_for_all_configurations], dtype=float)
return -K * self.temperature * log_z
16 changes: 8 additions & 8 deletions qha/multi_configurations/same_phonon_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def _static_part(self) -> Vector:
:return: The static contribution on the temperature-volume grid.
"""
try:
import bigfloat
import mpmath
except ImportError:
raise ImportError(
"You need to install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
"You need to install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))

with bigfloat.precision(self.precision):
return np.array([bigfloat.exp(d) for d in # shape = (# of volumes for each configuration, 1)
with mpmath.workprec(self.precision):
return np.array([mpmath.exp(d) for d in # shape = (# of volumes for each configuration, 1)
logsumexp(-self.static_energies / (K * self.temperature), axis=1, b=self.degeneracies)])

@property
Expand Down Expand Up @@ -124,12 +124,12 @@ def get_free_energies(self):
:return: The free energy on the temperature-volume grid.
"""
try:
import bigfloat
import mpmath
except ImportError:
raise ImportError("Install ``bigfloat`` package to use {0} object!".format(self.__class__.__name__))
raise ImportError("Install ``mpmath`` package to use {0} object!".format(self.__class__.__name__))

with bigfloat.precision(self.precision):
log_z = np.array([bigfloat.log(d) for d in self.total], dtype=float)
with mpmath.workprec(self.precision):
log_z = np.array([mpmath.log(d) for d in self.total], dtype=float)
return -K * self.temperature * log_z


Expand Down
4 changes: 2 additions & 2 deletions qha/tests/test_different_phonon_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import os
import unittest
from pathlib import Path

import numpy as np

from qha.calculator import DifferentPhDOSCalculator
from qha.multi_configurations.different_phonon_dos import PartitionFunction
from qha.settings import from_yaml


class TestPartitionFunction(unittest.TestCase):
def setUp(self) -> None:
os.chdir('../../examples/ice VII/')
os.chdir(Path(__file__).parent.parent.parent / 'examples/ice VII/')
self.user_settings = {}
settings = from_yaml("settings.yaml")

Expand Down
2 changes: 1 addition & 1 deletion qha/tests/test_overall_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TestOverallRun(unittest.TestCase):
def setUp(self):
self.root_directory = pathlib.Path('../../examples')
self.root_directory = pathlib.Path(__file__).parent.parent.parent / 'examples'
self.command = 'qha run'
self.fixed_directory = 'results.benchmark'
self.new_results_directory = 'results.plot'
Expand Down
2 changes: 1 addition & 1 deletion qha/tests/test_read_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TestReadInput(unittest.TestCase):
def setUp(self):
self.dir = pathlib.Path('../../examples')
self.dir = pathlib.Path(__file__).parent.parent.parent / 'examples'

def test_read_si_input(self):
file_path = self.dir / 'silicon/input'
Expand Down
2 changes: 1 addition & 1 deletion qha/tests/test_samevdos_overall.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TestSamePhononDOS(unittest.TestCase):
def setUp(self):
self.root_directory = pathlib.Path('../../examples')
self.root_directory = pathlib.Path(__file__).parent.parent.parent / 'examples'
self.command = 'qha run'
self.fixed_directory = 'results.benchmark'
self.new_results_directory = 'results.same_vdos_new01'
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ def find_version(*file_paths):
'Topic :: Scientific/Engineering :: Physics',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
python_requires='>=3.6, <3.7',
python_requires='>=3.6',
keywords='thermodynamic-properties quasi-harmonic-approximation scientific-computation',
install_requires=[
'lazy_property',
'mpmath',
'numba',
'numpy',
'bigfloat',
'pandas',
'scientific-string',
'scipy',
Expand Down

0 comments on commit 5937c10

Please sign in to comment.