Skip to content

amshirif/atom

Repository files navigation

atom logo

atom

Solidity Foundry License

A source-backed Solidity/Foundry project for simulating atoms, nuclides, and narrow chemistry previews on-chain.

Highlights

  • full periodic-table support through Z = 118
  • canonical electron state stored through subshell occupancy to 7p
  • state-aware nuclide metadata over ground | m1 | m2
  • deterministic one-step decay preview for source-backed radioactive parents
  • binary ionic, Lewis-style covalent, and core polyatomic-ion previews
  • packed onchain reference blobs generated from JSON source data
  • exhaustive generated parity tests plus handwritten behavioral tests

Example

AtomLab lab = AtomLab(atomLabAddress);

uint256 oxygenId = lab.createAtom(8, 8);
AtomLab.AtomDescription memory oxygen = lab.describeAtom(oxygenId);

AtomLab.DecayPreview memory uranium238 = lab.previewNuclideDecay(92, 146);

uint8[] memory atomicNumbers = new uint8[](2);
atomicNumbers[0] = 7;
atomicNumbers[1] = 8;

uint8[] memory counts = new uint8[](2);
counts[0] = 1;
counts[1] = 3;

AtomLab.CompoundPreview memory nitrate = lab.previewCompound(atomicNumbers, counts, -1);

Demo

A tiny static demo lives in demo/index.html.

It lets you:

  • enter Z, N, and electron count
  • inspect shell and subshell occupancy
  • preview one-step decay when supported
  • glance at NaCl, H2O, and NO3-

atom demo screenshot

Visualize Locally

From the repo root, start a simple static server:

python3 -m http.server

Then open http://localhost:8000/demo/.

The demo reads directly from the canonical JSON source files in data/, so if you regenerate reference data first, the visualization will reflect the current repo state.

Quickstart

python3 tools/generate_references.py
forge build
forge test

Release-check flow:

python3 tools/generate_references.py
forge fmt --check
forge test
forge build --sizes

Deployment Notes

Before deploying, make sure the generated artifacts are current:

python3 tools/generate_references.py

The deploy script then installs:

  1. packed reference blob contracts from generated/*.bin
  2. ChemistryLab
  3. AtomLab

Run:

forge script script/DeployAtomLab.s.sol:DeployAtomLab

The deploy path assumes the generated blobs in generated/ match the JSON source files in data/.

Project Layout

Scope Boundaries

This repo is strong on data discipline, but intentionally narrow in scientific scope:

  • not a general chemistry engine
  • not a quantum-chemistry solver
  • not a reaction engine
  • not a full decay-chain simulator

The current chemistry model is preview-only and limited to:

  • fixed-charge binary ionic compounds
  • a narrow neutral Lewis subset over H, C, N, O, F, P, S, Cl
  • a small template-backed polyatomic-ion set: OH-, NH4+, NO3-, CO3^2-, SO4^2-, PO4^3-

Read More

About

Source-backed onchain atom, nuclide, decay, and chemistry preview engine built with Solidity and Foundry

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors