muon-spectroscopy-computational-project / muon-galaxy

Data intensive science for everyone.
https://galaxyproject.org
Other
0 stars 0 forks source link

crystvis-js doesn't work if file contains H:mu or other unusual atoms #23

Open elichad opened 2 years ago

elichad commented 2 years ago

Describe the bug When trying to load a file like https://raw.githubusercontent.com/muon-spectroscopy-computational-project/muon-galaxy-tools/92b7688a0d7a74028896a42be6f430ce07735d51/pm_muairss_write/test-data/allpos.cell with custom atom labels, the crystvis-js visualiser loads indefinitely and the console has the error:

Uncaught The requested model does not exist

Having tested a bit, it seems that crystvis cannot parse the H:mu symbol. This is troublesome for any integration with our pymuonsuite tools.

Tried and confirmed not to be a problem:

Example file from link above:

#######################################################
#CASTEP cell file: allpos.cell
#Created using the Atomic Simulation Environment (ASE)#
#######################################################

%BLOCK LATTICE_CART
 5.475382  0.000000 -0.000000
 0.000000  5.475382  0.000000
-0.000000  0.000000  5.475382
%ENDBLOCK LATTICE_CART

%BLOCK POSITIONS_ABS
Si  0.000000  0.000000  0.000000
Si -0.000000  2.737691  2.737691
Si  1.368845  1.368845  1.368845
Si  2.737691  0.000000  2.737691
Si  1.368845  4.106536  4.106536
Si  4.106536  1.368845  4.106536
Si  4.106536  4.106536  1.368845
Si  2.737691  2.737691 -0.000000
H:mu  3.125152  3.041799  2.994236
H:mu  4.170048  2.685234  3.919204
H:mu  2.896190  3.055878  1.069474
H:mu  2.499357  2.738732  5.011782
H:mu  1.856384  1.305645  0.684300
H:mu  0.710100  1.663543  1.366143
H:mu  2.926805  4.554958  3.173796
H:mu  4.041556  2.285971  2.357787
H:mu  2.153772  1.685845  2.712357
H:mu  3.369247  0.881320  2.641127
H:mu  4.631185  3.830276  4.640470
H:mu  2.828731  1.963913  1.697286
H:mu  2.176625  2.144297  3.912156
H:mu  1.805850  2.882961  2.746759
H:mu  1.403305  0.559980  1.522521
H:mu  3.251047  3.565876  4.157223
%ENDBLOCK POSITIONS_ABS
patrick-austin commented 1 year ago

I've also struggled to get it to read .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.

patrick-austin commented 1 year ago

And some cif files won't load:

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.

patrick-austin commented 1 year ago

Issues with file types have been raised on active crystvis repo. Muon labelling may be something we can deal with in Galaxy, by using the castep custom label to identify the muons, and leaving the species label as H. Will need to investigate further. If this still doesn't work, may be able to add an exception to how crystvis loads to allow H:mu.