-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from p2ptrans import analysis, findMatching | ||
import pytest | ||
import os, glob | ||
import numpy as np | ||
from test_units import read_FCC_BCC, BCC_file, FCC_file, tol, cleanup | ||
import cProfile | ||
|
||
|
||
def default_options(): | ||
# (fileA, fileB, ncell, filename, interactive, savedisplay, outdir, | ||
# use, switch, prim, anim, vol, minimize, test, crystfile, n_steps, | ||
# showversion, map_ncell) | ||
return ('./POSCAR_A', './POSCAR_B', 300, './p2p.in', False, False, '.', | ||
False, False, True, False, False, False, False, './cryst.in', 60, | ||
False, None) | ||
|
||
if __name__ == "__main__": | ||
'''Runs a full matching, then tests that the tmats, dispCell, and first two dmins are the same''' | ||
cleanup() | ||
(_, _, ncell, filename, interactive, savedisplay, outdir, | ||
use, switch, prim, anim, vol, minimize, test, crystfile, n_steps, | ||
showversion, map_ncell) = default_options() | ||
|
||
BCC, FCC = read_FCC_BCC() | ||
|
||
if not os.path.exists(outdir): | ||
os.makedirs(outdir) | ||
|
||
try: | ||
with open(filename, "r") as f: | ||
filecontent = f.readlines() | ||
except FileNotFoundError: | ||
filecontent = "" | ||
|
||
ccell1, ccell2, planehkl, diruvw = analysis.readCrystParam('./FILE_DNE') | ||
|
||
matchCode = 'findMatching(BCC, FCC, ncell, fileA=BCC_file, fileB=FCC_file,'+\ | ||
'ccellA=ccell1, ccellB=ccell2,'+\ | ||
'filename=filename, interactive=interactive,'+\ | ||
'savedisplay=savedisplay, outdir=outdir,'+\ | ||
'switch=switch, prim=prim, vol=vol,'+\ | ||
'minimize=minimize, test=test, map_ncell=map_ncell)' | ||
|
||
cProfile.run(matchCode, 'stats') | ||
|
||
|
||
cleanup() |
3d6b833
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Ash-Pera, since there is randomness in the optimization and it makes it hard to test results that are equivalent under symmetry, I suggest that we set the seeds for the random numbers (or the random numbers themselves) in Fortran to a constant such that you can compare the results with numerical precision accuracy. I could add a
test
variable in the namelist (p2p.in) and iftest=.true.
we use the same exact seed. What do you think?3d6b833
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking through that one.
I think we definitely need the overall test of findMatching on the small unit cell, since it is very unlikely that it won't find the same mapping (that's the point, isn't it? ;).
While my first instinct is a yes on the set seed, my concern is that it might produce false failures. Where does it consume the random numbers? Is it just for the intial rotation/translation or are they also used elsewhere? I'm thinking of a senario where the LAP part is changed at it eats a different amount of random numbers. Maybe we should ditch this specific test in favor of an overall and a smaller test of LAP.
3d6b833
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but even for small unit cells there is still many symmetry equivalent results (100)/(100), (100)/(010), (100)/(001) which each have three combinations of directions + all the possible translations. Although the spheres themselves might not have as much symmetry. So definitely, that is one way to go about the problem, but there will be a lot of cases to consider.
Yes, the randomness is only in the initial rotation and translation.
I will let you decide which way you want to go. If you need my help to implement a testing fixed seed in Fortran, let me know.
Also, I suggest you create a Pull Request for the test branch and mark it as Work In Progress and we can take this discussion there.
Thanks so much for doing this!