From a fresh clone to real results in ten minutes.
You'll install Anvil, run a built-in relation, track units, solve a coupled system, sweep a parameter, and open the web workbench.
- Time
- ~10 min
- Needs
- Python 3.10 +
- Core
- numpy · scipy
Install
The fastest path is one command from the cloned repo. It creates a virtual environment, installs Anvil plus the web server, launches it, and opens the workbench in your browser. No Node, no npm.
$ python start_anvil.pyPrefer the library only, without the server? Install with pip and skip to step 02:
$ pip install -e . # core (numpy + scipy) $ pip install -e ".[server]" # + web workbench
anvil doctor any time to see which optional adapters (XFOIL, Cantera, CoolProp …) are available on your machine, with the exact install command for each.Your first calculation
Every built-in relation lives under anvil.R. Call one directly. Here, isentropic flow ratios for Mach 2 air:
import anvil anvil.R.isentropic_ratios(M=2.0, gamma=1.4) # {'T0_T': 1.8, 'P0_P': 7.824, 'rho0_rho': 4.347}
There are 101 relations across aero, propulsion, structures, heat transfer, orbital, thermo, controls, combustion, and signal processing. Browse them in the Wiki or the workbench's spotlight search.
Quantities carry units
Wrap values in Q and dimensions follow through every operation: conversions, arithmetic, even offset temperatures like degrees Celsius. Unit mistakes surface as errors instead of silent wrong answers.
from anvil import Q P = Q(101325, "Pa") P.to("psi") # 14.696 psi rho = Q(1.225, "kg/m^3") V = Q(50, "m/s") q = 0.5 * rho * V**2 # 1531.25 Pa (units derived)
Build and solve a system
A System is a graph of quantities and relations. Add your knowns, pull in relations with use(), and solve. Anvil orders the computation; when variables depend on each other in a cycle, it detects the coupling and switches to an iterative solver automatically.
from anvil import System hx = System("counter_flow_hx") hx.add("T_hot_in", 600, "K") hx.add("T_cold_in", 290, "K") hx.add("UA", 2000, "W") hx.add("Cp_hot", 1050, "J/kg/K") hx.add("Cp_cold", 4186, "J/kg/K") hx.add("mdot_hot", 0.8, "kg/s") hx.add("mdot_cold", 0.5, "kg/s") # initial guesses for the two coupled variables (Q_dot ↔ T_cold_out) hx.add("T_cold_out", 350, "K") hx.add("Q_dot", 50000, "W") hx.use("hx_heat_rate"); hx.use("hx_cold_out") hx.use("hx_hot_out"); hx.use("hx_effectiveness") result = hx.solve_gauss_seidel(monitor=True) result.summary() # ~19 iterations, effectiveness ~ 0.806
Other solvers: solve_forward() for acyclic systems and solve_newton() for stiff coupling. For ODE/BVP/PDE, reach into anvil.solvers.
Sweep and analyze
Vary a parameter across a range, then rank which inputs move your outputs the most. This coupled system converges best with under-relaxation, so the sweep passes the same solver settings.
import numpy as np sweep = hx.sweep("UA", np.linspace(500, 5000, 6), method="gauss_seidel", relaxation=0.5, max_iter=200) sweep.summary(outputs=["effectiveness", "Q_dot"]) sweep.to_csv("hx_sweep.csv") hx.sensitivity(outputs=["effectiveness"]).summary()
Open the workbench, call it anywhere
If you started with python start_anvil.py, the workbench is already running at http://127.0.0.1:8000: a calculator with spotlight search over every relation, and a node-graph canvas where you wire systems visually and watch solver residuals live. Canvases save as runnable Python.
The same running server is a REST API, so any code can drive it. From Python, use the built-in client:
from anvil.client import AnvilClient srv = AnvilClient("http://127.0.0.1:8000") srv.health() # {'status': 'ok', 'rsq_count': 108, ...} srv.call("isentropic_ratios", M=2.0, gamma=1.4)