[ctml_writer] Fix handling of units in some fields

When using Python 3, using -1 as the dummy value for density and site_density
causes probems, because the (ordered) comparison between a density specified
with units (as a tuple) and 0 is not allowed. Instead, use None as the
placeholder value.

Cherry-pick of trunk commit r2800.
This commit is contained in:
Ray Speth 2014-03-24 21:37:00 +00:00
parent 5795f3fd55
commit 1b0519e662

View file

@ -2016,7 +2016,7 @@ class incompressible_solid(phase):
elements = '',
species = '',
note = '',
density = -1.0,
density = None,
transport = 'None',
initial_state = None,
options = []):
@ -2025,7 +2025,7 @@ class incompressible_solid(phase):
initial_state, options)
self._dens = density
self._pure = 0
if self._dens < 0.0:
if self._dens is None:
raise CTI_Error('density must be specified.')
self._tr = transport
@ -2054,7 +2054,7 @@ class lattice(phase):
transport = 'None',
initial_state = None,
options = [],
site_density = -1.0,
site_density = None,
vacancy_species = ''):
phase.__init__(self, name, 3, elements, species, note, 'none',
initial_state, options)
@ -2066,7 +2066,7 @@ class lattice(phase):
raise CTI_Error('sublattice name must be specified')
if species == '':
raise CTI_Error('sublattice species must be specified')
if site_density < 0.0:
if site_density is None:
raise CTI_Error('sublattice '+name
+' site density must be specified')