Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script>
window.coi = { coepCredentialless: () => true };
</script>
<script src="/atomify/coi-serviceworker.min.js"></script>
<script src="coi-serviceworker.min.js"></script>
</head>

<body>
Expand Down
65 changes: 65 additions & 0 deletions public/examples/diffusion/large_diffusion/large_diffusion.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Large system: run with KOKKOS multithreading (Atomify detects this line)
suffix kk

# Atomify commands start with #/

# Move camera to a nice position
#/camera position 50.0 72.7 221.7
#/camera target 45.7 51.3 35.0

# Set atom size and color
#/atom 1 1.0 #ffffff
#/atom 2 1.5 #ff0000

variable L equal 50.0
variable Lhalf equal $(0.5*v_L)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In LAMMPS, using immediate evaluation $(...) inside an equal style variable definition is redundant and can be simplified. Defining Lhalf as a standard formula 0.5*v_L is cleaner and more idiomatic.

variable Lhalf equal 0.5*v_L

variable thickness equal 2.0

units lj
atom_style atomic
lattice fcc 0.5

# Create regions to place atoms
variable left equal 0.5*$L-0.5*${thickness}
variable right equal 0.5*$L+0.5*${thickness}
Comment on lines +23 to +24

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In LAMMPS, equal-style variables should reference other variables using the v_name syntax (e.g., v_L and v_thickness) rather than immediate text substitution ($L and ${thickness}). Using v_name ensures that the formulas are evaluated dynamically and follow standard LAMMPS scripting best practices.

variable left equal 0.5*v_L-0.5*v_thickness
variable right equal 0.5*v_L+0.5*v_thickness

region system block 0 $L 0 $L 0 ${Lhalf}
region boxinside block ${left} ${right} 0 $L 0 ${Lhalf}
region boxoutside block ${left} ${right} 0 $L 0 ${Lhalf} side out

# Create a box with 2 atom types in the region system
create_box 2 system
# Create atoms of type 1 inside the inner region
create_atoms 1 region boxinside
# Create atoms of type 2 inside the outer region
create_atoms 2 region boxoutside

# Set atom masses
mass 1 1.0
mass 2 4.0

# Give initial velocity, T=3.00, seed = 1337
velocity all create 3.00 1337 loop geom

# Choose LJ with 2.5sigma cutoff
pair_style lj/cut 2.5
pair_coeff * * 1.0 1.0 2.5
neigh_modify every 1 delay 0 check yes

# Create two groups for computing diffusion coefficients
group light type 1
group heavy type 2

# Measure mean square displacement and diffusion coefficient
compute msd_light light msd com yes
variable diffusion_coeff_light equal c_msd_light[4]/6/(step*dt+1.0e-6)
variable msd_light equal c_msd_light[4]

compute msd_heavy heavy msd com yes
variable msd_heavy equal c_msd_heavy[4]
variable diffusion_coeff_heavy equal c_msd_heavy[4]/6/(step*dt+1.0e-6)

thermo 100
thermo_style custom step v_diffusion_coeff_light v_msd_light v_diffusion_coeff_heavy v_msd_heavy
fix 1 all nve
compute displace all displace/atom
run 10000
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 46 additions & 26 deletions public/examples/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@
}
]
},
{
"id": "large_diffusion",
"title": "Large diffusion",
"description": "A large version of the diffusion example (~250,000 atoms) that runs multithreaded with KOKKOS. The white atoms have mass 1 while the red atoms have mass 4.",
"analysisDescription": "# About this simulation\nWe simulate two Lennard Jones particle types with masses 1.0 and 4.0. The diffusion coefficient [https://en.wikipedia.org/wiki/Mass_diffusivity](scales like) D$\\propto 1/\\sqrt{m}$, so we should see a factor 2 higher diffusion coefficient for the small molecules.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The markdown link syntax in analysisDescription is inverted. In markdown, the format is [link text](URL). It should be [scales like](https://en.wikipedia.org/wiki/Mass_diffusivity) instead of [https://en.wikipedia.org/wiki/Mass_diffusivity](scales like).

Suggested change
"analysisDescription": "# About this simulation\nWe simulate two Lennard Jones particle types with masses 1.0 and 4.0. The diffusion coefficient [https://en.wikipedia.org/wiki/Mass_diffusivity](scales like) D$\\propto 1/\\sqrt{m}$, so we should see a factor 2 higher diffusion coefficient for the small molecules.",
"analysisDescription": "# About this simulation\nWe simulate two Lennard Jones particle types with masses 1.0 and 4.0. The diffusion coefficient [scales like](https://en.wikipedia.org/wiki/Mass_diffusivity) D$\\propto 1/\\sqrt{m}$, so we should see a factor 2 higher diffusion coefficient for the small molecules.",

"imageUrl": "diffusion/large_diffusion/large_diffusion.png",
"inputScript": "large_diffusion.in",
"keywords": [
"lennard jones",
"diffusion",
"kokkos",
"large"
],
"files": [
{
"fileName": "large_diffusion.in",
"url": "diffusion/large_diffusion/large_diffusion.in"
}
]
},
{
"id": "2d-msd-diffusion",
"title": "2D diffusion coefficient MSD",
Expand All @@ -40,34 +60,34 @@
"url": "diffusion/2d-msd-diffusion/2d-msd-diffusion.in"
},
{
"fileName": "2d-msd-diffusion.ipynb",
"url": "diffusion/2d-msd-diffusion/2d-msd-diffusion.ipynb"
}
"fileName": "2d-msd-diffusion.ipynb",
"url": "diffusion/2d-msd-diffusion/2d-msd-diffusion.ipynb"
}
]
},
{
"id": "2d-vacf-diffusion",
"title": "2D diffusion coefficient VACF",
"description": "We measure the diffusion coefficient using the velocity auto correlation function.",
"analysisDescription": "# About this simulation\nWe measure the diffusion coefficient using the velocity auto correlation function.",
"analysisScript": "2d-vacf-diffusion.ipynb",
"imageUrl": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.png",
"inputScript": "2d-vacf-diffusion.in",
"keywords": [
"lennard jones",
"diffusion",
"velocity autocorrelation function"
],
"files": [
{
"fileName": "2d-vacf-diffusion.in",
"url": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.in"
},
{
"fileName": "2d-vacf-diffusion.ipynb",
"url": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.ipynb"
}
]
"id": "2d-vacf-diffusion",
"title": "2D diffusion coefficient VACF",
"description": "We measure the diffusion coefficient using the velocity auto correlation function.",
"analysisDescription": "# About this simulation\nWe measure the diffusion coefficient using the velocity auto correlation function.",
"analysisScript": "2d-vacf-diffusion.ipynb",
"imageUrl": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.png",
"inputScript": "2d-vacf-diffusion.in",
"keywords": [
"lennard jones",
"diffusion",
"velocity autocorrelation function"
],
"files": [
{
"fileName": "2d-vacf-diffusion.in",
"url": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.in"
},
{
"fileName": "2d-vacf-diffusion.ipynb",
"url": "diffusion/2d-vacf-diffusion/2d-vacf-diffusion.ipynb"
}
]
},
{
"id": "proteinfolding",
Expand Down Expand Up @@ -1410,4 +1430,4 @@
]
}
]
}
}
36 changes: 35 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
import { defineConfig } from "vite";
import { createRequire } from "node:module";
import { createReadStream, statSync } from "node:fs";
import { defineConfig, type Plugin } from "vite";
import react from "@vitejs/plugin-react";
import basicSsl from "@vitejs/plugin-basic-ssl";

/**
* Dev-only: serve the ~43 MB lammps-atomify.js emscripten module RAW.
* The worker loads it via `?url` + fetch-as-blob (see lammps.worker.ts) —
* it is never bundled — but Vite's dev transform would otherwise rewrite it
* and append an inline sourcemap, inflating the download to ~460 MB (which
* can crash the tab). This middleware runs before Vite's transform and
* streams the file as-is. `?url`/`?import` requests (the tiny URL-shim
* module) still go through Vite untouched.
*/
function serveLammpsModuleRaw(): Plugin {
return {
name: "serve-lammps-atomify-raw",
apply: "serve",
configureServer(server) {
const require = createRequire(import.meta.url);
// Resolve via the package's exports map (the raw dist path is not an
// exported subpath).
const filePath = require.resolve("lammps.js/wasm-atomify");
server.middlewares.use((req, res, next) => {
const url = req.url ?? "";
if (!url.includes("lammps-atomify.js") || url.includes("?")) {
return next();
}
res.setHeader("Content-Type", "text/javascript");
res.setHeader("Content-Length", statSync(filePath).size);
createReadStream(filePath).pipe(res);
});
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
serveLammpsModuleRaw(),
// Only enable HTTPS if HTTPS environment variable is set
...(process.env.HTTPS === "true" ? [basicSsl()] : []),
],
Expand Down
Loading