Skip to content

Commit

Permalink
add /new-dielectric-materials post
Browse files Browse the repository at this point in the history
move oss.yml and papers.yaml to $lib for cleaner imports
add chiang_llamp_2024 preprint to papers.yaml
pnpm add --dev elementari (used in dielectrics post to render 3D crystals)
  • Loading branch information
janosh committed Jan 31, 2024
1 parent 0988577 commit ea51fa4
Show file tree
Hide file tree
Showing 22 changed files with 1,399 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -34,7 +34,7 @@ repos:
- id: codespell
stages: [commit, commit-msg]
exclude_types: [svg]
args: [--ignore-words-list, 'ist,yau', --check-filenames]
args: [--ignore-words-list, 'ist,yau,te', --check-filenames]

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.0.0-alpha.0
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"devalue": "^4.3.2",
"elementari": "^0.2.3",
"eslint": "^8.56.0",
"eslint-plugin-svelte": "^2.35.1",
"hast-util-from-string": "^3.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/app.css
Expand Up @@ -198,3 +198,9 @@ input {
color: mediumaquamarine;
text-decoration: underline;
}

img.banner {
max-height: 25em;
object-fit: cover;
width: 100%;
}
1 change: 1 addition & 0 deletions src/lib/DocsGrid.svelte
Expand Up @@ -22,6 +22,7 @@
display: grid;
font-size: larger;
font-weight: bolder;
color: inherit;
}
:global(div.grid img) {
width: 100%;
Expand Down
12 changes: 6 additions & 6 deletions src/routes/open-source/oss.yml → src/lib/oss.yml
Expand Up @@ -25,7 +25,7 @@ projects:
- JavaScript
- HTML
stars: 52
commits: 303
commits: 304
- name: CHGNet
url: https://chgnet.lbl.gov
repo: https://github.com/CederGroupHub/chgnet
Expand All @@ -50,7 +50,7 @@ projects:
paper: riebesell_foundation_2023
description: Fast and accurate machine learning interatomic potentials with higher order equivariant message passing.
logo: https://avatars.githubusercontent.com/u/68508620
stars: 291
stars: 294
commits: 21
languages:
- Python
Expand All @@ -67,7 +67,7 @@ projects:
- JavaScript
- HTML
stars: 103
commits: 173
commits: 174
- name: pymatviz
url: https://pymatviz.janosh.dev
img_style: 'filter: invert(1);'
Expand Down Expand Up @@ -98,7 +98,7 @@ projects:
description: Curated list of resources for learning and using normalizing flows, a powerful tool in ML for modeling probability distributions.
languages:
- Python
stars: 1245
stars: 1247
commits: 72
- name: atomate2
repo: https://github.com/materialsproject/atomate2
Expand All @@ -111,7 +111,7 @@ projects:
languages:
- Python
stars: 113
commits: 348
commits: 349
- name: jobflow
repo: https://github.com/materialsproject/jobflow
role: Maintainer
Expand Down Expand Up @@ -181,5 +181,5 @@ projects:
- CSS
- HTML
- JavaScript
stars: 245
stars: 247
commits: 269
26 changes: 26 additions & 0 deletions src/routes/cv/papers.yaml → src/lib/papers.yaml
@@ -1,5 +1,31 @@
---
references:
- id: chiang_llamp_2024
accessed:
- year: 2024
month: 1
day: 31
author:
- family: Chiang
given: Yuan
- family: Chou
given: Chia-Hong
- family: Riebesell
given: Janosh
citation-key: chiang_llamp_2024
issued:
- year: 2024
month: 1
day: 30
number: arXiv:2401.17244
publisher: arXiv
source: arXiv.org
title: >-
LLaMP: Large Language Model Made Powerful for High-fidelity Materials
Knowledge Retrieval and Distillation
title-short: LLaMP
URL: http://arxiv.org/abs/2401.17244

- id: deng_chgnet_2023
accessed:
- year: 2023
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.server.ts
@@ -1,5 +1,5 @@
import type { FrontMatter } from '$lib/types.js'
import { author } from '$root/package.json'
import type { FrontMatter } from '../lib/types.js'

export const prerender = true

Expand Down
4 changes: 2 additions & 2 deletions src/routes/+page.svelte
@@ -1,9 +1,9 @@
<script lang="ts">
import GdmSLides from '$lib/2024-01-12-deepmind-interview.pdf'
import oss from '$lib/oss.yml'
import { references } from '$lib/papers.yaml'
import Icon from '@iconify/svelte'
import { references } from './cv/papers.yaml'
import OpenSource from './open-source/+page.svelte'
import oss from './open-source/oss.yml'
import Physics from './physics/+page@.md'
import Posts from './posts/+page@.svelte'
Expand Down
4 changes: 2 additions & 2 deletions src/routes/cv/+page.svelte
@@ -1,9 +1,9 @@
<script lang="ts">
import oss from '$lib/oss.yml'
import papers from '$lib/papers.yaml'
import Icon from '@iconify/svelte'
import oss from '../open-source/oss.yml'
import Papers from './Papers.svelte'
import cv from './cv.yml'
import papers from './papers.yaml'
export let data
Expand Down
11 changes: 10 additions & 1 deletion src/routes/cv/Papers.svelte
@@ -1,13 +1,19 @@
<script lang="ts">
import type { Reference } from '$lib'
import { highlight_matches } from 'svelte-zoo'
import { truncate_authors } from './utils'
export let references: Reference[]
export let first_name_mode: 'initial' | 'full' | 'none' = `initial`
export let target_author: string = `J. Riebesell`
</script>

<ol>
<ol
use:highlight_matches={{
query: target_author.toLowerCase(),
css_class: `highlight-match`,
}}
>
{#each references.sort(({ author }) => {
return -(author[0].family == target_author.split(` `)[1])
}) as { title, id, author, DOI, URL: href, issued } (id)}
Expand Down Expand Up @@ -54,4 +60,7 @@
margin: 8pt 0 2pt;
font-size: small;
}
::highlight(highlight-match) {
color: initial;
}
</style>
6 changes: 0 additions & 6 deletions src/routes/cv/utils.ts
Expand Up @@ -2,7 +2,6 @@ export function truncate_authors(
author_str: string,
target_name: string,
max_authors: number = 3,
wrap_target_auth: string = `<span style="text-decoration: underline">{}</span>`,
): string {
// show at most max_authors, including the target author, replacing the rest with ellipsis
const authors = author_str.split(`, `)
Expand Down Expand Up @@ -44,10 +43,5 @@ export function truncate_authors(
truncated_str += `, ${truncated_authors[idx]}`
}

truncated_str = truncated_str.replace(
target_name,
wrap_target_auth.replace(`{}`, target_name),
)

return truncated_str
}
2 changes: 1 addition & 1 deletion src/routes/open-source/+page.svelte
@@ -1,8 +1,8 @@
<script lang="ts">
import oss from '$lib/oss.yml'
import Icon from '@iconify/svelte'
import { highlight_matches } from 'svelte-zoo'
import { flip } from 'svelte/animate'
import oss from './oss.yml'
let sort_by: 'commits' | 'stars' | 'alphabetical' = `commits`
const sort_by_options = [`commits`, `stars`, `alphabetical`] as const
Expand Down
4 changes: 2 additions & 2 deletions src/routes/physics/+page@.md
Expand Up @@ -12,7 +12,7 @@ cover:
import Icon from '@iconify/svelte'
</script>

<img src="./planets.svg" alt={cover.caption} style="margin: 2em 0 0;" />
<img src="./planets.svg" alt={cover.caption} class="banner" />

<h2 class="section-title">
<Icon inline icon="mdi:atom" />
Expand All @@ -21,7 +21,7 @@ cover:

This is a compilation of notes and solutions to problem sheets for some of the physics lectures I took, most of them in [Heidelberg](https://google.com/search?q=Heidelberg). Hopefully, they can be useful to others. If you find errors, please [open an issue]({issues}).

<DocsGrid style="max-width: var(--body-max-width);">
<DocsGrid style="max-width: var(--body-max-width); margin: 0 0 5em;">

[String Theory ![Cross section of the quintic Calabi–Yau manifold](./string-theory/calabi-yau.png)](physics/string-theory)

Expand Down
6 changes: 5 additions & 1 deletion src/routes/posts/+page@.svelte
Expand Up @@ -39,7 +39,7 @@
}
</script>

<img src="./blog-banner.svg" alt="Banner" style="margin: 2em 0 0;" />
<img src="./blog-banner.svg" alt="Banner" class="banner" />

<h2 class="section-title">
<Icon inline icon="ri:article-line" />
Expand Down Expand Up @@ -107,6 +107,10 @@
text-overflow: ellipsis;
overflow: hidden;
text-align: center;
align-self: end;
}
ul > li > h3 > a {
color: inherit;
}
ul > li > a > img {
border-radius: 2pt;
Expand Down
70 changes: 70 additions & 0 deletions src/routes/posts/new-dielectric-materials/+page.md
@@ -0,0 +1,70 @@
---
title: New Dielectric Materials
date: 2024-01-29
cover:
img: dielectric-banner.svg
origin: Vecteezy
url: https://vecteezy.com/vector-art/192230-robot-character-design
tags:
- Tutorial
- Python
---

<script>
import { references } from '$lib/papers.yaml'
import { projects } from '$lib/oss.yml'
import { Structure, StructureCard } from 'elementari'

const diel_paper = references.find((ref) => ref.id === `riebesell_pushing_2024`)
const elementari = projects.find((proj) => proj.name === `Elementari`)

const structs = import.meta.glob(`./*.json`, { as: `raw`, eager: true })
</script>

[We just published data on two materials]({diel_paper.URL}), Zr<sub>2</sub>Bi<sub>2</sub>O<sub>7</sub> and CsTaTeO<sub>6</sub>, which were the result of a workflow to discover new dielectric materials. Dielectrics are in used CPUs and SSDs among many other electronic devices. We managed to experimentally synthesize both these materials and measure their dielectric properties (thanks Wes!), so I wanted to take the opportunity of having two crystal structures that are special to me to write a short tutorial on how to render 3D crystal structures in a browser using one of my side-projects called [`elementari`]({elementari.repo}).

`elementari` currently only understands `pymatgen`'s JSON-like structure representation. Converting the CIF files you get from (of the structures we verified with [XRD](https://wikipedia.org/wiki/X-ray_crystallography) to have made in the lab) to this format is easy:

```py
from glob import glob

import pymatgen.transformations.advanced_transformations as pat
from pymatgen.core import Structure

for cif in glob("*.cif"):
struct = Structure.from_file(cif).add_oxidation_state_by_guess()
# remove partial occupancies, elementari does not support them (yet)
ordered = pat.OrderDisorderedStructureTransformation().apply_transformation(struct)
ordered.to(cif.replace(".cif", ".json"))
```

The resulting JSON files can then be visualized with `elementari` using the `Structure` component which again takes only half a dozen lines of code:

```svelte
<script>
import { Structure, StructureCard } from 'elementari'
const structs = import.meta.glob(`./*.json`, { as: `raw`, eager: true })
</script>
{#each Object.entries(structs) as [name, json_struct]}
{@const structure = JSON.parse(json_struct)}
<StructureCard {structure} />
<Structure {structure} />
{/each}
```

Here's what this code renders:

<div style="display: grid; gap: 1em;">
{#each Object.entries(structs) as [name, json_struct]}
{@const structure = JSON.parse(json_struct)}
{@const [formula, spacegroup] = name.match(/\.\/(.+)-(.+)\.json/).slice(1)}
<section>
<StructureCard {structure} title="{formula} (<small>{spacegroup}</small>)" />
<Structure {structure} show_bonds={false} show_site_labels />
</section>
{/each}
</div>

Note that the converted CIFs give us `pymatgen` `Structures`, not `StructureGraphs` which contain adjacency matrices to convey bond information. `elementari` can render bonds but `StructureGraph` support is still WIP and the JS code I wrote for on-the-fly bond detection is terrible (don't use it). Hopefully, something I'll fix in the coming months.

0 comments on commit ea51fa4

Please sign in to comment.