diff --git a/index.html b/index.html index bf6efd99..f2a7762d 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@ - + diff --git a/public/examples/diffusion/large_diffusion/large_diffusion.in b/public/examples/diffusion/large_diffusion/large_diffusion.in new file mode 100644 index 00000000..487ce5fd --- /dev/null +++ b/public/examples/diffusion/large_diffusion/large_diffusion.in @@ -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) +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} +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 \ No newline at end of file diff --git a/public/examples/diffusion/large_diffusion/large_diffusion.png b/public/examples/diffusion/large_diffusion/large_diffusion.png new file mode 100644 index 00000000..87cfa359 Binary files /dev/null and b/public/examples/diffusion/large_diffusion/large_diffusion.png differ diff --git a/public/examples/examples.json b/public/examples/examples.json index b1b41cc6..33ec712f 100644 --- a/public/examples/examples.json +++ b/public/examples/examples.json @@ -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.", + "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", @@ -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", @@ -1410,4 +1430,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/vite.config.ts b/vite.config.ts index e1007365..c0791add 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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()] : []), ],