Skip to content

Commit

Permalink
Merge pull request #79 from jotelha/202107_electrochemistry_tests_fix
Browse files Browse the repository at this point in the history
202107 electrochemistry tests fix
  • Loading branch information
pastewka authored Jul 29, 2021
2 parents 41e0ad0 + 919ed89 commit 23be0e4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gitignore
.idea

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
4 changes: 2 additions & 2 deletions examples/electrochemistry/samples_pnp_by_fenics_fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.6.0
# jupytext_version: 1.9.1
# kernelspec:
# display_name: Python 3
# language: python
Expand Down Expand Up @@ -84,7 +84,7 @@ def make_patch_spines_invisible(ax):
# # Convergence in both cases

# %%
# Test case parameters
# Test case parameters
c=[1.0, 1.0]
z=[ 1, -1]
L=10e-8 # 200 nm
Expand Down
4 changes: 2 additions & 2 deletions scripts/electrochemistry/c2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def __call__(self, parser, namespace, values, option_string=None):

if not args.outfile:
outfile = sys.stdout
outfile_format = 'xyz'
outfile_format = '.xyz'
else:
outfile = args.outfile
_, outfile_format = os.path.splitext(outfile)
Expand All @@ -302,7 +302,7 @@ def __call__(self, parser, namespace, values, option_string=None):
# species names have been specified on command line.

else: # elif outfile_format == '.xyz'
ase.io.write(outfile, system, format='xyz')
ase.io.write(outfile, system, format='extxyz')

logger.info('Done.')

Expand Down
6 changes: 3 additions & 3 deletions scripts/electrochemistry/stericify.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __call__(self, parser, namespace, value, option_string=None):
system = ase.io.read(
infile, format='lammps-data', units="real", style='full')
else: # elif outfile_format == '.xyz'
system = ase.io.read(infile, format='xyz')
system = ase.io.read(infile, format='extxyz')

n = len(system) # total number of particles
logger.info('Read "{}" system within bounding box'.format(system.symbols))
Expand Down Expand Up @@ -364,7 +364,7 @@ def __call__(self, parser, namespace, value, option_string=None):

if not args.outfile:
outfile = sys.stdout
outfile_format = 'xyz'
outfile_format = '.xyz'
else:
outfile = args.outfile
_, outfile_format = os.path.splitext(outfile)
Expand All @@ -377,7 +377,7 @@ def __call__(self, parser, namespace, value, option_string=None):
format='lammps-data', units="real", atom_style='full',
specorder=specorder)
else: # elif outfile_format == '.xyz'
ase.io.write(outfile, system, format='xyz')
ase.io.write(outfile, system, format='extxyz')

logger.info('Done.')

Expand Down
12 changes: 6 additions & 6 deletions tests/test_c2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_c2d_input_format_npz_output_format_xyz(self):
[ 'c2d', os.path.join(self.data_path,'NaCl.npz'), 'NaCl.xyz' ],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=tmpdir, env=self.myenv)
xyz = ase.io.read(os.path.join(tmpdir,'NaCl.xyz'))
xyz = ase.io.read(os.path.join(tmpdir,'NaCl.xyz'), format='extxyz')
self.assertEqual(len(xyz),len(self.ref_xyz))
self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
self.assertTrue( ( xyz.get_initial_charges() ==
Expand All @@ -88,12 +88,12 @@ def test_c2d_input_format_txt_output_format_xyz(self):
[ 'c2d', os.path.join(self.data_path,'NaCl.txt'), 'NaCl.xyz' ],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=tmpdir, env=self.myenv)
xyz = ase.io.read(os.path.join(tmpdir,'NaCl.xyz'))
xyz = ase.io.read(os.path.join(tmpdir,'NaCl.xyz'), format='extxyz')
self.assertEqual(len(xyz), len(self.ref_xyz))
self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
self.assertTrue( ( xyz.get_initial_charges()
== self.ref_xyz.get_initial_charges() ).all() )
self.assertTrue( ( xyz.cell == self.ref_xyz.cell ).all() )
== self.ref_xyz.get_initial_charges() ).all() )
self.assertTrue( ( xyz.cell == self.ref_xyz.cell ).all() )

@unittest.skipUnless(LooseVersion(ase.__version__) > LooseVersion('3.19.0'),
""" LAMMPS data file won't work for ASE version up until 3.18.1,
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_pnp_c2d_pipeline_mode(self):

c2d_output = c2d.communicate()[0]
with io.StringIO(c2d_output) as xyz_instream:
xyz = ase.io.read(xyz_instream, format='xyz')
xyz = ase.io.read(xyz_instream, format='extxyz')
self.assertEqual(len(xyz),len(self.ref_xyz))
self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
self.assertTrue( ( xyz.get_initial_charges()
Expand Down

0 comments on commit 23be0e4

Please sign in to comment.