pierrehirel / atomsk

Atomsk: A Tool For Manipulating And Converting Atomic Data Files -
https://atomsk.univ-lille.fr
GNU General Public License v3.0
198 stars 75 forks source link

atomsk --polycrystal gives errors on long angles X an Y #40

Closed jfikar closed 2 years ago

jfikar commented 2 years ago

Hi Pierre,

I'm trying to construct a polycrystal with random rotation angles X, Y, Z, which are generated by a bash script using bc -l. The file looks for example like this:

box 400 346.4102 200
node .24991958618164062500*box -.00027902221679687500*box .49998059082031250000*box -.74890136718750000000 -.34616088867187500000 153.36914062500000000000
node .75041552734375000000*box .00015951538085937500*box .50008172607421875000*box .47927856445312500000 .99719238281250000000 -125.78247070312500000000
node .49960971069335937500*box .50042877197265625000*box .49974542236328125000*box -1.24319458007812500000 .69607543945312500000 -83.96850585937500000000
node .00046789550781250000*box .50009417724609375000*box .50021948242187500000*box -.93054199218750000000 .88842773437500000000 -158.66455078125000000000

Recent atomsk gives an error:

$ atomsk --polycrystal Al.xsf poly00.txt poly.cfg -wrap
  ___________________________________________________
 |              ___________                          |
 |     o---o    A T O M S K                          |
 |    o---o|    Version master                       |
 |    |   |o    (C) 2010 Pierre Hirel                |
 |    o---o     https://atomsk.univ-lille.fr         |
 |___________________________________________________|
 *** I am hungry! :-p
 >>> Constructing a polycrystal using Voronoi method.
 >>> Opening the input file: Al.xsf
 ..> Input file was read successfully (2 atoms).
 >>> Reading parameters for Voronoi construction from: poly00.txt
 X!X ERROR: there were errors while reading the file: poly00.txt
           Error appears to be at line # 2
 \o/ Program terminated successfully!
     Total time: 0.001 s.; CPU time: 0.001 s.
  ___________________________________________________
 |  X!X ERRORS:   1                                  |
 |___________________________________________________|

Removing three zeroes at the end of angle X or Y does cure the problem. This is strange, probably something related to the optional degree sign? My workaround for now is to use for angle Y scale=10 (up to 17) to limit the number of digits printed by bc -l and with this atomsk works.

pierrehirel commented 2 years ago

Hello Jan,

The problem came from the fact that lines were stored in a string of 128 characters, which I assumed would be enough for most practical purposes. You just proved me wrong :-)

I just increased the line size to 4096 (hopefully now it should be enough!), and pushed the fix on GitHub. Can you please try it and tell me if it works?

As a side note, one of the nodes in your file is out of the box (the one with negative coordinate). Atomsk will now warn about that and wrap this position so that it is inside the box.

Best Pierre

jfikar commented 2 years ago

Yes, it works. Thank you very much.

The position of nodes are also slightly disturbed by a small random number. I saw couple of the warnings already, but I'm not worried about it as the result looks as expected.