Skip to content

comphy-lab/sl25

Repository files navigation

SL Theory Website

SL Theory Website

Small Flask app for exploring the drop-impact scaling theory described in the paper linked below. The browser collects Weber number We and Ohnesorge number Oh, then calls JSON endpoints to compute Reynolds number, classify the impact regime, and predict BetaMax. The homepage also supports batch CSV uploads for beta predictions.

What's in the repo

SLtheoryWebsite/
  app.py
  batchProcess.py
  calculateReynoldsNumber.py
  deploy.sh
  regimeDecide.py
  phase_diagram_svg.py
  SLtheory_prediction.py
  SLtheory_model.json
  static/
    site.css
    site.js
  templates/index.html
  requirements.txt
  runtime.txt
  vercel.json

app.py creates the Flask app, registers the blueprints, caps request bodies at 1 MB, and runs the server locally. calculateReynoldsNumber.py serves the homepage and computes Reynolds number. regimeDecide.py classifies the regime from We and Oh and returns the model-based predBeta prediction using SLtheory_prediction.py and SLtheory_model.json. batchProcess.py accepts CSV uploads with We and Oh columns, reuses the same theory-range validation as /regime, and returns a CSV with beta filled in or error for invalid rows. The phase diagram is rendered in Python by phase_diagram_svg.py. The frontend is split between templates/index.html, static/site.css, and static/site.js.

Local run

pip install -r requirements.txt
python app.py

Or use the helper script to create a virtualenv, install dependencies, and start the local server in one step:

chmod +x deploy.sh
./deploy.sh

By default the script serves the app at http://127.0.0.1:5000. You can override the port from the CLI with ./deploy.sh 8000 or ./deploy.sh --port 8000. You can still override the bind address or default port with environment variables such as HOST=0.0.0.0 PORT=8000 ./deploy.sh.

The app is configured for Python 3.9 in runtime.txt.

Endpoints

  • GET / renders the single-page UI from templates/index.html.
  • POST /add expects JSON like {"weberNumber": 10, "ohnesorgeNumber": 0.1} with 1 <= We <= 10^3 and 10^-3 <= Oh <= 10^2, and returns {"result": <Re>} rounded to two decimals.
  • POST /regime expects the same JSON and range bounds, and returns {"regime": "I" | "II" | "III" | "IV", "predBeta": <BetaMax>} with predBeta rounded to two decimals.
  • POST /batch expects multipart/form-data with a .csv file field named file. The CSV must contain We and Oh headers, uses the same 1 <= We <= 10^3 and 10^-3 <= Oh <= 10^2 limits as /regime, and returns a CSV download with a beta column. Invalid rows are marked as error and summarized in X-Row-Errors. Uploads larger than 1 MB are rejected with HTTP 413.
  • GET /regime-diagram.svg returns a server-rendered SVG of the Weber-Ohnesorge phase diagram. Optional weberNumber, ohnesorgeNumber, and theme query parameters add the current input marker and match the active light or dark theme.

The frontend calls /add and /regime separately after the user submits the input form, then renders Re, Regime, and predBeta together. Numeric results are rounded in the Python endpoints and displayed to two decimal places in the UI. Inputs outside the theory range are rejected in both the browser and the Flask routes. The regime figure is generated by Python and returned as SVG.

Deployment

vercel.json routes all traffic to app.py using @vercel/python, so Vercel is the intended deployment target.

Notes

  • The code validates that inputs are present, JSON object shaped, numeric, finite, and positive before doing the Reynolds, regime, or predBeta calculations, and batch CSV rows reuse the same theory-range validation.
  • Flask-SocketIO is used to run the app locally, but there are no socket event handlers in the current app.
  • The page loads MathJax and a polyfill from external CDNs and embeds a YouTube iframe, so full rendering depends on external network access.

About

This is a website to render the results of SL theory, https://arxiv.org/abs/2408.12714

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors