Sweeps
A sweep runs the same test at many settings in one request. Use it to see how thrust and current change as the throttle goes up, or to compare several propellers at the same throttle. One sweep is faster than many single simulations, and it counts as one submission.
Sweep the throttle
A sweep takes everything a simulation takes, plus a sweep setting that says what to vary. That includes the air as altitude_m or density_kg_m3, and the wires as a gauge and a length. This sweep runs a quadcopter from 10 to 100 percent throttle in 10 points:
from thrustlab import Client
client = Client()
project = client.projects.create(name="Throttle sweeps")
motor = client.components.find(name="BadAss 2826-820Kv")
prop = client.components.find(name="10.5x4.5")
battery = client.components.find(
name="Liperior 5000mAh 4S 35C 14.8V Lipo Battery With XT90 Plug"
)
sweep = client.sweeps.create(
project_id=project["id"],
battery_component_id=battery["id"],
airspeed_m_s=0.0,
density_kg_m3=1.225,
rotor_groups=[
{
"label": "main",
# Four rotors need the Pro plan. On the Free plan, use "count": 1.
"count": 4,
"motor_component_id": motor["id"],
"propeller_component_id": prop["id"],
"throttle_pct": 70,
}
],
sweep={
"rotor_sweep_mask": [True],
"throttle": {"mode": "range", "start": 10, "stop": 100, "steps": 10},
},
)
done = client.sweeps.wait(sweep["id"], timeout=600)Every sweep needs rotor_sweep_mask. It has one true or false for each rotor group, in the same order. True means that group follows the swept throttle.
steps counts the points. It is not the gap between them. This range gives 10, 20, 30 and so on up to 100, and both ends are included.
Read the points
When the sweep is completed, read its points:
for point in client.sweeps.list_points(sweep["id"]):
rotor = point["rotors"]["1"]
print(point["inputs"]["throttle"], rotor["thrust_n"], point["rotors"]["All"]["total_thrust_n"])Each point has an index, the inputs that made it, and rotors. That is laid out like the result of a single simulation, with an entry for each rotor and an "All" entry. A point that couldn't be solved has failed set to true.
While the sweep runs, total_points and completed_points on the sweep show how far along it is.
What you can vary
Each setting in sweep is either a range, {"mode": "range", "start": 10, "stop": 100, "steps": 10}, or a list you choose, {"mode": "custom", "values": [10, 25, 90]}. A range has 2 to 1000 points, and a custom list has up to 1000 values.
| Setting | What it varies |
|---|---|
throttle | Throttle, in percent. |
airspeed | Forward speed. |
density | Air density. |
state_of_charge | Battery state of charge at the start, in percent. |
resting_voltage | Battery voltage at the start, in volts per cell. Use this or state_of_charge. |
vertical_speed | Climb or descent speed. |
esc_timing_advance_deg, esc_pwm_frequency_khz | Settings of a six-step speed controller. |
component_axes | Which motor, propeller or battery to use. |
You can vary several settings at once. The sweep then runs every combination, and a whole sweep may have at most 10,000 points. Your plan may set a lower limit. To see how big a sweep is allowed to be, call client.simulations.limits(), or client.simulations.estimate(rotor_groups, points=...) to see how long yours should take.
Compare parts
A part axis swaps in different parts at each point. This compares four propellers at four throttle settings, 16 points in one request:
props = client.components.list(type="propeller", limit=4).data
prop_ids = [p["id"] for p in props]
sweep = client.sweeps.create(
project_id=project["id"],
battery_component_id=battery["id"],
airspeed_m_s=0.0,
density_kg_m3=1.225,
rotor_groups=[
{
"label": "main",
# Four rotors need the Pro plan. On the Free plan, use "count": 1.
"count": 4,
"motor_component_id": motor["id"],
"propeller_component_id": prop_ids[0],
"throttle_pct": 70,
}
],
sweep={
"rotor_sweep_mask": [True],
"throttle": {"mode": "range", "start": 40, "stop": 100, "steps": 4},
"component_axes": [
{"axis": "propeller", "slots": [0], "component_ids": prop_ids}
],
},
)slots lists the rotor groups that take the swept part, counting from 0. An axis needs at least two parts. Each point names the part it used in point["inputs"]["component"].
Test bench settings
A sweep takes start, hold_s, window_s and the battery start, the same as a simulation. Every point is its own test bench run. All points are read at one time.
Cancel or list sweeps
client.sweeps.cancel(sweep_id) stops a sweep. A waiting sweep stops now. A running sweep stops after the point it is working on. client.sweeps.list(project_id=...) lists your sweeps.