Skip to content

Commit

Permalink
Merge branch 'master' into ci-update
Browse files Browse the repository at this point in the history
  • Loading branch information
kip-hart committed Jul 11, 2020
2 parents 1ce74d4 + fa60e4b commit 0e4ebdf
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 14 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_,
and this project adheres to `Semantic Versioning`_.

`Unreleased`_
`1.3.2`_ - 2020-07-11
--------------------------
Added
'''''
- VTK output for 2D triangular meshes.

Changed
'''''''
- Updated reference to CMAME publication.

`1.3.1`_ - 2020-07-09
--------------------------
Added
'''''
- VTK output for seed lists and polyhedral meshes.
- Option to compute expected area of ellipse from area distribution.
- Option to compute expected volume of ellipsoid from volume distribution.

Fixed
'''''
- Error in verification module for 2D uniform random orientations.

Changed
'''''''
Expand Down Expand Up @@ -123,7 +139,9 @@ Added

.. LINKS
.. _`Unreleased`: https://github.com/kip-hart/MicroStructPy/compare/v1.3.0...HEAD
.. _`Unreleased`: https://github.com/kip-hart/MicroStructPy/compare/v1.3.2...HEAD
.. _`1.3.2`: https://github.com/kip-hart/MicroStructPy/compare/v1.3.1...v1.3.2
.. _`1.3.1`: https://github.com/kip-hart/MicroStructPy/compare/v1.3.0...v1.3.1
.. _`1.3.0`: https://github.com/kip-hart/MicroStructPy/compare/v1.2.2...v1.3.0
.. _`1.2.2`: https://github.com/kip-hart/MicroStructPy/compare/v1.2.1...v1.2.2
.. _`1.2.1`: https://github.com/kip-hart/MicroStructPy/compare/v1.2.0...v1.2.1
Expand Down
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ in your bibliography:
K. A. Hart and J. J. Rimoli, Generation of statistically representative
microstructures with direct grain geomety control,
*Computer Methods in Applied Mechanics and Engineering*,
in press.
370 (2020), pp. 113242.
(`BibTeX <https://github.com/kip-hart/MicroStructPy/raw/master/docs/publications/cmame2020.bib>`_)
(`DOI <https://doi.org/10.1016/j.cma.2020.113242>`_)

.. end-publications
Expand Down Expand Up @@ -188,6 +189,6 @@ advised by Prof. Julian Rimoli.
:target: https://github.com/kip-hart/MicroStructPy/blob/master/LICENSE.rst
:alt: License

.. |s-doi| image:: https://zenodo.org/badge/206468500.svg
:target: https://zenodo.org/badge/latestdoi/206468500
.. |s-doi| image:: https://img.shields.io/badge/DOI-10.1016%2Fj.cma.2020.113242-blue
:target: https://doi.org/10.1016/j.cma.2020.113242
:alt: DOI
9 changes: 8 additions & 1 deletion docs/publications/cmame2020.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ @article{Hart2020
author = {Hart, Kenneth A and Rimoli, Julian J},
title = {Generation of statistically representative microstructures with direct grain geomety control},
journal = {Computer Methods in Applied Mechanics and Engineering},
year = {in press},
volume = {370},
pages = {113242},
year = {2020},
issn = {0045-7825},
doi = "https://doi.org/10.1016/j.cma.2020.113242",
url = "http://www.sciencedirect.com/science/article/pii/S0045782520304278",
keywords = "Microstructure, Polycrystal, Finite element modeling, Laguerre tessellation, Multi-sphere",
abstract = "Microstructural characteristics play a significant role in the determination of effective properties of materials. Consequently, most numerical tools aimed at predicting such properties require, as a starting point, the availability of geometric representations of such microstructures. In this paper, we introduce a method for generating statistically representative synthetic microstructures for materials involving multiple phases. Our method is based on traditional seed placement and tessellation approaches, with three critical improvements: (i) allowing for controlled seed overlap to better represent microstructural statistics, (ii) multi-sphere representation of 3D ellipsoids to account for arbitrarily elongated grains, and (iii) novel application of the axis aligned bounding box tree structure for accelerated seed placement. Our method recreates a diverse set of microstructural features, including the presence of spherical and non-spherical grain geometries, amorphous phases, and voids. After the method is presented, we proceed with a rigorous numerical analysis demonstrating its ability to reproduce key statistical features of target microstructures. The algorithms presented are freely available and open source through the package MicroStructPy."
}
2 changes: 1 addition & 1 deletion src/microstructpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
import microstructpy.seeding
import microstructpy.verification

__version__ = '1.3.0'
__version__ = '1.3.2'
8 changes: 8 additions & 0 deletions src/microstructpy/geometry/ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ def volume_expectation(cls, **kwargs):
return 0.5 * np.pi * s_dist * s_dist * s_dist / 3
return 0.5 * np.pi * s_dist.moment(3) / 3

if 'volume' in kwargs:
v_dist = kwargs['volume']
try:
v_exp = v_dist.moment(1)
except AttributeError:
v_exp = v_dist
return v_exp

# check for a, b, and c distribution
try:
exp_vol = 4 * np.pi / 3
Expand Down
8 changes: 8 additions & 0 deletions src/microstructpy/geometry/m_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ def area_expectation(cls, **kwargs):
return 0.25 * np.pi * s_dist * s_dist
return 0.25 * np.pi * s_dist.moment(2)

if 'area' in kwargs:
a_dist = kwargs['area']
try:
a_exp = a_dist.moment(1)
except AttributeError:
a_exp = a_dist
return a_exp

if ('a' in kwargs) and ('b' in kwargs):
exp = np.pi
for kw in ('a', 'b'):
Expand Down
21 changes: 14 additions & 7 deletions src/microstructpy/meshing/trimesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,28 +590,35 @@ def write(self, filename, format='txt', seeds=None, polymesh=None):
file.write(edge)

elif fmt == 'vtk':
assert len(self.points[0]) == 3
n_kp = len(self.elements[0])
mesh_type = {3: 'Triangular', 4: 'Tetrahedral'}[n_kp]
pt_fmt = '{: f} {: f} {: f}\n'
# write heading
vtk = '# vtk DataFile Version 2.0\n'
vtk += 'Tetrahedral mesh\n'
vtk += '{} mesh\n'.format(mesh_type)
vtk += 'ASCII\n'
vtk += 'DATASET UNSTRUCTURED_GRID\n'

# Write points
vtk += 'POINTS ' + str(len(self.points)) + ' float\n'
vtk += ''.join([pt_fmt.format(x, y, z) for x, y, z in self.points])
if len(self.points[0]) == 2:
vtk += ''.join([pt_fmt.format(x, y, 0) for x, y in
self.points])
else:
vtk += ''.join([pt_fmt.format(x, y, z) for x, y, z in
self.points])

# write elements
n_elem = len(self.elements)
cell_sz = 5 * n_elem
cell_fmt = str(n_kp) + n_kp * ' {}' + '\n'
cell_sz = (1 + n_kp) * n_elem
vtk += '\nCELLS ' + str(n_elem) + ' ' + str(cell_sz) + '\n'
vtk += ''.join(['4 ' + ' '.join([str(k) for k in el]) + '\n' for
el in self.elements])
vtk += ''.join([cell_fmt.format(*el) for el in self.elements])

# write cell type
vtk += '\nCELL_TYPES ' + str(n_elem) + '\n'
vtk += ''.join(n_elem * ['10\n'])
cell_type = {3: '5', 4: '10'}[n_kp]
vtk += ''.join(n_elem * [cell_type + '\n'])

# write element attributes
try:
Expand Down
5 changes: 5 additions & 0 deletions src/microstructpy/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,11 @@ def error_stats(fit_seeds, seeds, phases, poly_mesh=None, verif_mask=None):
i_phase = init_phases[i]
o_phase = outp_phases[i]
phase = phases[i]
for kw in phase:
if kw in ('angle', 'angle_deg') and phase[kw] == 'random':
phase[kw] = scipy.stats.uniform(loc=0, scale=360)
if kw == 'angle_rad':
phase[kw] = scipy.stats.uniform(loc=0, scale=2 * np.pi)

err_io = {kw: _kw_errs(i_phase[kw], o_phase[kw]) for kw in i_phase}
err_po = {kw: _kw_stats(phase[kw], o_phase[kw]) for kw in o_phase}
Expand Down

0 comments on commit 0e4ebdf

Please sign in to comment.