Structure

Bi2Zr2O8-Fm3m.json

No structure provided

❓ unknownπŸ”· crystal🧬 molecule   CIF EXTXYZ JSON POSCAR XYZ YAML
❓ AgI-fq978185p-phono3py.yaml.gz πŸ“¦
πŸ”· BaTiO3-tetragonal.poscar
❓ BeO-zw12zc18p-phono3py.yaml.gz πŸ“¦
πŸ”· Bi2Zr2O8-Fm3m.json
πŸ”· Li10GeP2S12.cif
πŸ”· Li4Fe3Mn1(PO4)4.cif
πŸ”· Li8Fe2NiCoO8.cif
πŸ”· LiFePO4.cif
πŸ”· MgNiF6.cif
πŸ”· NaCl-cubic.poscar
πŸ”· P24Ru4H252C296S24N16.cif
πŸ”· PF-sd-1601634.cif
πŸ”· TiO2.cif
πŸ”· TlBiSe2-highly-oblique-cell.json
πŸ”· aviary-CuF3K-triolith.poscar
πŸ”· mof-issue-127.cif
πŸ”· mp-1.json
πŸ”· mp-10018-Ac1-cubic.json
❓ mp-1183057-Ac3-trigonal.json.gz πŸ“¦
πŸ”· mp-1183085-Ac4Mg2-orthorhombic.json
πŸ”· mp-1183089-Ac4Mg2-monoclinic.json
πŸ”· mp-1204603.json
πŸ”· mp-1207297-Ac2Br2O1-tetragonal.json
πŸ”· mp-1229155.json
πŸ”· mp-1229168.json
πŸ”· mp-1234.json
πŸ”· mp-12712.json
❓ mp-19017.json.gz πŸ“¦
πŸ”· mp-2.json
πŸ”· mp-686119-Ag13Bi14I56-triclinic.json
πŸ”· mp-7000-optimade.json
πŸ”· mp-756175.json
πŸ”· mp-862690-Ac4-hexagonal.json
❓ nested-Hf36Mo36Nb36Ta36W36-hcp-mace-omat.json.gz πŸ“¦
πŸ”· quartz-alpha.cif
πŸ”· quartz.extxyz
πŸ”· scientific-notation.poscar
πŸ”· selective-dynamics.poscar
πŸ”· vasp4-format.poscar
🧬 C2HO-scientific-notation.xyz
🧬 C5-extra-data.xyz
🧬 benzene.json
🧬 cyclohexane.xyz
🧬 ethanol.json
🧬 methane.json
🧬 methyl.json
🧬 water.json
  <script>
  import { page } from '$app/state'
  import { goto } from '$app/navigation'
  import { browser } from '$app/environment'
  import { Structure } from 'matterviz'
  import Select from 'svelte-multiselect'
  import { structure_files } from '$site/structures'
  import { molecule_files } from '$site/molecules'
  import { FilePicker, get_electro_neg_formula } from '$lib'

  let current_filename = $state(`Bi2Zr2O8-Fm3m.json`)

  $effect(() => {
    if (!browser) return
    const file = page.url.searchParams.get(`file`)
    if (file && file !== current_filename) current_filename = file
  })
</script>

<Structure
  data_url="/structures/{current_filename}"
  on_file_load={(data) => {
    current_filename = data.filename
    page.url.searchParams.set(`file`, current_filename)
    goto(`${page.url.pathname}?${page.url.searchParams.toString()}`, {
      replaceState: true,
      keepFocus: true,
      noScroll: true,
    })
  }}
>
  <h3 style="position: absolute; margin: 1ex 1em; font-family: monospace; z-index: 1">
    {current_filename}
  </h3>
</Structure>

<FilePicker
  files={[...structure_files, ...molecule_files]}
  show_category_filters
  style="margin-block: 2em"
/>

Different Crystal Systems

Showcasing structures with different crystal systems.

  <script>
  import { crystal_systems, Structure } from 'matterviz'
  import { structures } from '$site/structures'
</script>

<ul class="crystal-systems">
  {#each structures.filter((struct) =>
      crystal_systems.some((system) => struct.id.includes(system))
    ) as
    structure
  }
    {@const mp_id = structure.id.split(`-`).slice(0, 2).join(`-`)}
    {@const href = `https://materialsproject.org/materials/${mp_id}`}
    {@const crystal_system = structure.id.split(`-`).at(-1) || 'unknown'}
    <li>
      <h3><a {href}>{mp_id}</a> <small>{crystal_system}</small></h3>
      <Structure {structure} />
    </li>
  {/each}
</ul>

Load Structure from String

You can load structures directly from text content using the structure_string prop, supporting various formats (CIF, POSCAR, XYZ, JSON, etc.).

No structure provided

  <script>
  import { Structure } from 'matterviz'
  import { format_num } from '$lib'
  import c2ho_scientific_notation_xyz from '$site/molecules/C2HO-scientific-notation.xyz?raw'
  import c5_extra_data_xyz from '$site/molecules/C5-extra-data.xyz?raw'
  import cyclohexane from '$site/molecules/cyclohexane.xyz?raw'
  import aviary_CuF3K_triolith from '$site/structures/aviary-CuF3K-triolith.poscar?raw'
  import ba_ti_o3_tetragonal from '$site/structures/BaTiO3-tetragonal.poscar?raw'
  import mof_issue_127 from '$site/structures/mof-issue-127.cif?raw'
  import na_cl_cubic from '$site/structures/NaCl-cubic.poscar?raw'
  import ru_p_complex_cif from '$site/structures/P24Ru4H252C296S24N16.cif?raw'
  import pf_sd_1601634_cif from '$site/structures/PF-sd-1601634.cif?raw'
  import extended_xyz_quartz from '$site/structures/quartz.extxyz?raw'
  import scientific_notation_poscar from '$site/structures/scientific-notation.poscar?raw'
  import selective_dynamics from '$site/structures/selective-dynamics.poscar?raw'
  import tio2_cif from '$site/structures/TiO2.cif?raw'
  import vasp4_format from '$site/structures/vasp4-format.poscar?raw'

  const structure_files = [
    { name: `MOF (CIF)`, content: mof_issue_127 },
    { name: `Ru Complex (CIF)`, content: ru_p_complex_cif },
    { name: `PF Structure (CIF)`, content: pf_sd_1601634_cif },
    { name: `Cyclohexane (XYZ)`, content: cyclohexane },
    { name: `C2HO (XYZ)`, content: c2ho_scientific_notation_xyz },
    { name: `C5 (XYZ)`, content: c5_extra_data_xyz },
    { name: `CuF3K (POSCAR)`, content: aviary_CuF3K_triolith },
    { name: `BaTiO3 (POSCAR)`, content: ba_ti_o3_tetragonal },
    { name: `NaCl (POSCAR)`, content: na_cl_cubic },
    { name: `Quartz (ExtXYZ)`, content: extended_xyz_quartz },
    { name: `Scientific Notation (POSCAR)`, content: scientific_notation_poscar },
    { name: `Selective Dynamics (POSCAR)`, content: selective_dynamics },
    { name: `TiO2 (CIF)`, content: tio2_cif },
    { name: `VASP4 Format (POSCAR)`, content: vasp4_format },
  ]

  let selected_idx = $state(0)
  let parsed_structure = $state(undefined)
  let selected_file = $derived(structure_files[selected_idx])
</script>

<label style="display: block; margin-block: 1em">
  Structure:
  <select bind:value={selected_idx}>
    {#each structure_files as file, idx (file.name)}
      <option value={idx}>{file.name}</option>
    {/each}
  </select>
  &ensp;(parsed <strong>{parsed_structure?.sites?.length || 0}</strong> atoms from {
    format_num(selected_file.content.length)
  }B)
</label>

<Structure
  structure_string={selected_file.content}
  bind:structure={parsed_structure}
/>