Component analyses

A component analysis tests one part on its own: a propeller, a motor or a battery, without building a whole drone around it. You can look at one operating point, sweep a setting, search for the setting that hits a target, or compare several parts.

Find the rpm that gives 5 newtons

The air in inputs is altitude_m or density_kg_m3. Use only one of the two. This example takes a propeller you describe by its printed size, and searches for the rpm where it makes 5 N of thrust in 10 m/s of airflow:

python
from thrustlab import Client

client = Client()

job = client.component_analyses.create(
    component_type="propeller",
    custom_spec={
        "model": "label",
        "diameter_m": 0.254,
        "pitch_m": 0.127,
        "num_blades": 2,
        "family": "thin_electric",
        "camber_pct": 3.9,
    },
    model="fast",
    mode="solve_target",
    inputs={
        "v_axial_mps": 10.0,
        "v_edge_mps": 0.0,
        "density_kg_m3": 1.225,
        "ambient_temp_c": 25.0,
    },
    variables=[{"parameter": "rpm", "min": 1000.0, "max": 15000.0, "steps": 25}],
    target={"metric": "thrust_n", "value": 5.0, "tolerance": 0.01},
)
done = client.component_analyses.wait(job["id"])
if done["status"] != "completed":
    raise RuntimeError(done.get("error") or done["status"])

for candidate in done["result"]["candidates"]:
    if candidate["feasible"]:
        print(candidate["rank"], candidate["scenarios"][0]["metrics"])

create returns a job. wait checks on it until it finishes. A job that fails comes back with its error, so check status before you read the result. When every evaluation fails, the job is failed with the code evaluation_failed and the engine's sentence about the first one, which names the input to change.

Choose the part

Name the part in one of these three ways, and only one:

  • component_id, a part from the catalog or one of your own.
  • candidate_ids, a list of up to 32 parts to compare.
  • custom_spec, a part you describe in the request. It is not saved. A propeller you describe by its printed size has "model": "label", with diameter_m, pitch_m, num_blades and family.

Choose the mode

mode says what to do. The default is "point".

Choose the mode
ModeWhat it does
pointEvaluates one operating point.
sweepEvaluates a set of values for the variables you give.
solve_targetSearches for the value of a variable that reaches your target.
optimizeSearches for the best value of your objective, within your constraints.
sensitivityShows how much each variable changes the outcome.
compare_modelsCompares the Fast and Full propeller models. Propellers only.

A variables list names what may change. Each variable has a parameter and either a min, max and steps, or a list of values. You can have up to 4 variables. max_evaluations limits the search and defaults to 256.

Operating values use SI units, with rpm for speed and degrees for angles. A propeller's model is "fast" or "full". The Fast model runs from the printed size. The Full model runs from measured blade geometry.

Motors and batteries

A motor analysis takes more arguments. They are esc_settings for the speed controller model, battery_component_id to power it from a battery, and load_propeller_component_id to turn a propeller as the load. It also reads the test bench inputs start, hold_s and window_s. Simulations explains those.

The dq-voltage drive was removed. Asking for it raises a RemovedFeatureError before anything is sent. Use a throttle input (throttle_pct, percent).

A battery analysis takes a load such as current_a or power_w and reports how the battery behaves over duration_s.

Wait, check and cancel

python
done = client.component_analyses.wait(job["id"], timeout=300, poll_interval=1)

wait returns when the job is completed, failed or cancelled. If the time runs out, it returns the job with the status timed_out. That status comes from the library, and the job keeps running on the server. on_progress takes a function that is called with the job after every check.

retrieve(job_id) reads a job once. cancel(job_id) asks the job to stop, and a finished result stays readable. A job passes through queued, running and cancelling on its way. Component analyses spell it cancelled with two l's. Runs use canceled with one.

Results are kept for 24 hours, so save what you need.