levisim.web.server¶
Local HTTP server and JSON API for the interactive levisim Three.js web labs.
Launch from the command line via:
levisim-web # serves on http://127.0.0.1:8765 and opens browser
levisim-web --port 8080 --no-open # serve without opening a browser tab
python -m levisim.web --lab tweezer # open directly to the free-space tweezer lab
Only the Python standard library is used for HTTP serving; physics calculations
delegate directly to levisim.physics and levisim.analysis.
- levisim.web.server.compute_tweezer_spectra(params)[source]¶
Computes live free-space tweezer motional and optical spectra using
Trap.- Parameters:
params (dict) – Physical parameters (laser power, waists, wavelength, bead radius, gas pressure and temperature, cold feedback damping, directed force strength/angle, detection floor, photon recoil flag, and frequency grid).
- Returns:
JSON-serialisable dictionary with frequency grid (kHz), one-sided motional PSDs
Sxx,Syy,Szz[m²/Hz], co-/quad-spectraCxy,Qxy[m²/Hz], thermal baselines, balanced optical detector spectra in shot-noise units, and derived trap telemetry.- Return type:
- levisim.web.server.run_tweezer_simulation(params)[source]¶
Runs a short stochastic Kasdin RK4
Simulationand returns Bartlett spectral estimates.
- levisim.web.server.dispatch_request(method, path, body=b'', *, static_dir=None, three_dir=None)[source]¶
Dispatches an HTTP request to static lab assets or JSON physics APIs.
Returns
(status_code, content_type, body_bytes, cache_control).
- levisim.web.server.create_server(host='127.0.0.1', port=8765, *, static_dir=None, three_dir=None)[source]¶
Creates a threaded HTTP server for the
levisimThree.js web interfaces.- Parameters:
host (str) – Interface to bind (default
'127.0.0.1').port (int) – TCP port (
0selects an ephemeral port).static_dir (Path, optional) – Override directory containing static web assets.
three_dir (Path, optional) – Optional local directory of the
threenpm package so HTML pages can load Three.js from/vendor/three/without internet access.
- Returns:
Ready-to-serve threaded HTTP server instance.
- Return type: