CCP-NC / crystvis-js

A Three.js based crystallographic visualisation tool
https://ccp-nc.github.io/crystvis-js/
MIT License
0 stars 0 forks source link

Issues with specific file types #2

Closed patrick-austin closed 1 year ago

patrick-austin commented 1 year ago

XYZ files

8
Generated by cif2cell 2.0.0.  :  Kitano, A. et al., Physical Review, Serie 3. B - Condensed Matter (18,1978-) 64, 0452061-0452069 (2001).
Si    0.000000000000000   0.000000000000000   0.000000000000000
Si    4.035750000000000   4.035750000000000   1.345250000000000
Si    2.690500000000000   0.000000000000000   2.690500000000000
Si    4.035750000000000   1.345250000000000   4.035750000000000
Si    0.000000000000000   2.690500000000000   2.690500000000000
Si    1.345250000000000   1.345250000000000   1.345250000000000
Si    1.345250000000000   4.035750000000000   4.035750000000000
Si    2.690500000000000   2.690500000000000   0.000000000000000

Fails with Uncaught TypeError: r is null - potentially due to the lack of lattice vectors? Whereas:

8
Lattice="5.47545112629462 4.96819156878786e-36 1.10608096941637e-36 4.96819156878786e-36 5.47545112629462 -3.12695835139248e-36 1.10608096941637e-36 -3.12695835139248e-36 5.47545112629462" Properties=species:S:1:pos:R:3:initial_magmoms:R:1:castep_labels:S:1 pbc="T T T"
Si       0.00000000       0.00000000       0.00000000       0.00000000 NULL
Si       4.10658834       4.10658834       1.36886278       0.00000000 NULL
Si       2.73772556       0.00000000       2.73772556       0.00000000 NULL
Si       4.10658834       1.36886278       4.10658834       0.00000000 NULL
Si       0.00000000       2.73772556       2.73772556       0.00000000 NULL
Si       1.36886278       1.36886278       1.36886278       0.00000000 NULL
Si       1.36886278       4.10658834       4.10658834       0.00000000 NULL
Si       2.73772556       2.73772556      -0.00000000       0.00000000 NULL

Fails with Uncaught Error: Invalid file format, I tried removing the initial_magmoms and castep_labels columns but that didn't help.

Originally posted by @patrick-austin in https://github.com/muon-spectroscopy-computational-project/muon-galaxy/issues/23#issuecomment-1332189159

Having looked into this further, suspect the issue with the latter is the e-36 not being parsed correctly from the Lattice. The former will not work as it doesn't have a cell/lattice defined, so ideally this should be documented in the README and a clear error thrown.

CIF files

data_global
_chemical_name_mineral 'Calcite'
loop_
_publ_author_name
'Graf D L'
_journal_name_full 'American Mineralogist'
_journal_volume 46
_journal_year 1961
_journal_page_first 1283
_journal_page_last 1316
_publ_section_title
;
 Crystallographic tables for the rhombohedral carbonates
;
_database_code_amcsd 0000098
_chemical_formula_sum 'Ca C O3'
_chemical_formula_sum ''
_cell_length_a 4.9900
_cell_length_b 4.9900
_cell_length_c 17.0615
_cell_angle_alpha 90
_cell_angle_beta 90
_cell_angle_gamma 120
_cell_volume 367.916
_exptl_crystal_density_diffrn      2.710
_symmetry_space_group_name_H-M 'R -3 c'
loop_
_space_group_symop_operation_xyz
  'x,y,z'
  '2/3+x,1/3+y,1/3+z'
  '1/3+x,2/3+y,2/3+z'
  'x,x-y,1/2+z'
  '2/3+x,1/3+x-y,5/6+z'
  '1/3+x,2/3+x-y,1/6+z'
  'y,x,1/2-z'
  '2/3+y,1/3+x,5/6-z'
  '1/3+y,2/3+x,1/6-z'
  '-x+y,y,1/2+z'
  '2/3-x+y,1/3+y,5/6+z'
  '1/3-x+y,2/3+y,1/6+z'
  '-x,-x+y,1/2-z'
  '2/3-x,1/3-x+y,5/6-z'
  '1/3-x,2/3-x+y,1/6-z'
  '-y,-x,1/2+z'
  '2/3-y,1/3-x,5/6+z'
  '1/3-y,2/3-x,1/6+z'
  'x-y,-y,1/2-z'
  '2/3+x-y,1/3-y,5/6-z'
  '1/3+x-y,2/3-y,1/6-z'
  'y,-x+y,-z'
  '2/3+y,1/3-x+y,1/3-z'
  '1/3+y,2/3-x+y,2/3-z'
  '-x+y,-x,z'
  '2/3-x+y,1/3-x,1/3+z'
  '1/3-x+y,2/3-x,2/3+z'
  '-x,-y,-z'
  '2/3-x,1/3-y,1/3-z'
  '1/3-x,2/3-y,2/3-z'
  '-y,x-y,z'
  '2/3-y,1/3+x-y,1/3+z'
  '1/3-y,2/3+x-y,2/3+z'
  'x-y,x,-z'
  '2/3+x-y,1/3+x,1/3-z'
  '1/3+x-y,2/3+x,2/3-z'
loop_
_atom_site_label
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
Ca   0.00000   0.00000   0.00000
C   0.00000   0.00000   0.25000
O   0.25780   0.00000   0.25000

Fails with Uncaught The requested model does not exist, despite containing only Ca, C, O, whereas:

data_image0
_cell_length_a       2.52437
_cell_length_b       2.52437
_cell_length_c       2.52437
_cell_angle_alpha    60
_cell_angle_beta     60
_cell_angle_gamma    60

_symmetry_space_group_name_H-M    "P 1"
_symmetry_int_tables_number       1

loop_
  _symmetry_equiv_pos_as_xyz
  'x, y, z'

loop_
  _atom_site_label
  _atom_site_occupancy
  _atom_site_fract_x
  _atom_site_fract_y
  _atom_site_fract_z
  _atom_site_thermal_displace_type
  _atom_site_B_iso_or_equiv
  _atom_site_type_symbol
  C1       1.0000 0.00000  0.00000  0.00000  Biso   1.000  C
  C2       1.0000 0.25000  0.25000  0.25000  Biso   1.000  C

Works fine.

Originally posted by @patrick-austin in https://github.com/muon-spectroscopy-computational-project/muon-galaxy/issues/23#issuecomment-1332199621

I'm not familiar with the CIF format so not sure what the problem might be here - the first one may simply be incorrectly formatted.

jkshenton commented 1 year ago

Thanks a lot for raising these issues! I've linked to the relevant fixes to crystvis-js and crystcif-parse so all should be working now.

I also put in a simple notification system, so major issues parsing files etc. should now be rendered in the canvas itself.

I haven't yet updated the package on npm but will do that soon.