Client SDK examples
No API key yet? Run these first. The three examples in this section are
pure-Python closed-form references — paste them straight into a Jupyter cell and they
run instantly (no API key, no upload, no GPU). The Client-SDK examples further down submit
real GPU jobs server-side and need an API key.
A1 — Eddy-current skin depth (runs with no setup)
# Proprietary and confidential. Copyright Secrotec / Eba Turan. All rights reserved.
import math, json
def skin_depth(freq_hz=50.0, sigma_s_per_m=2.0e6, mu_r=1000.0):
"""delta = 1 / sqrt(pi * f * mu * sigma). Jackson, Classical Electrodynamics, Ch. 8."""
mu0 = 4.0 * math.pi * 1e-7
delta = 1.0 / math.sqrt(math.pi * freq_hz * mu_r * mu0 * sigma_s_per_m)
return {"ok": True, "phase": "A/J", "example": "eddy-current skin depth",
"method": "closed-form EM skin depth",
"reference": "Jackson, Classical Electrodynamics, Ch. 8",
"verdict": "ANALYTICAL_CPU_OK",
"metrics": {"freq_hz": freq_hz, "skin_depth_mm": round(delta * 1e3, 4)},
"notes": ["pure stdlib math; no API key, no file, no GPU"]}
print(json.dumps(skin_depth(), indent=2))
A2 — Rotating-disk burst safety factor (runs with no setup)
# Proprietary and confidential. Copyright Secrotec / Eba Turan. All rights reserved.
import math, json
def rotating_disk_safety(rpm=10000.0, R=0.10, rho=7700.0, nu=0.29, sigma_yield=250e6):
"""Solid spinning-disk peak hoop stress + burst-speed safety factor.
Timoshenko and Goodier, Theory of Elasticity, Sec. 73."""
omega = 2.0 * math.pi * rpm / 60.0
sigma_hoop_max = (3.0 + nu) / 8.0 * rho * omega**2 * R**2
return {"ok": True, "phase": "C", "example": "rotating-disk burst safety factor",
"method": "closed-form solid-disk elasticity",
"reference": "Timoshenko and Goodier, Theory of Elasticity, Sec. 73",
"verdict": "ANALYTICAL_CPU_OK",
"metrics": {"rpm": rpm, "sigma_hoop_max_MPa": round(sigma_hoop_max / 1e6, 3),
"safety_factor": round(sigma_yield / sigma_hoop_max, 2)},
"notes": ["pure stdlib math; runs instantly"]}
print(json.dumps(rotating_disk_safety(), indent=2))
A3 — 1-D steady conduction slab (runs with no setup)
# Proprietary and confidential. Copyright Secrotec / Eba Turan. All rights reserved.
import json
def slab_conduction(k=45.0, area_m2=0.01, thickness_m=0.02, T_hot=120.0, T_cold=40.0):
"""1-D steady Fourier conduction: q = k A (T_hot - T_cold) / L. Incropera, Ch. 3."""
q = k * area_m2 * (T_hot - T_cold) / thickness_m
R = thickness_m / (k * area_m2)
return {"ok": True, "phase": "B", "example": "1-D steady slab conduction",
"method": "Fourier law closed form",
"reference": "Incropera, Fundamentals of Heat and Mass Transfer, Ch. 3",
"verdict": "ANALYTICAL_CPU_OK",
"metrics": {"heat_flow_W": round(q, 3), "thermal_resistance_K_per_W": round(R, 4)},
"notes": ["pure stdlib; no deps"]}
print(json.dumps(slab_conduction(), indent=2))
Client-SDK examples (need an API key)
These submit real GPU jobs to the
platform. Create a key under API keys and set
CUFEMLAB_API_KEY first — otherwise they raise
AuthenticationError.
01 — Demo motor quick check
import os
from cufemlab_client import Client
client = Client(api_key=os.environ["CUFEMLAB_API_KEY"])
job = client.submit_job(
analysis_type="demo_motor_quick_check",
input_params={"current_a": 12.0, "stator_od_m": 0.20},
max_minutes=5,
)
result = client.wait(job.id)
print(result.verdict, result.value)
02 — Cogging sweep (2-D)
import os
from cufemlab_client import Client
client = Client(api_key=os.environ["CUFEMLAB_API_KEY"])
# upload geometry file
file_id = client.upload(project_id=None, path="motor_2d.dxf")
job = client.submit_job(
analysis_type="cogging_sweep_2d",
input_params={"angle_deg": [0, 30, 60, 90]},
input_file_ids=[file_id],
max_minutes=20, gpu=True,
)
print(client.wait(job.id).summary())
03 — Iron-loss estimate
import os
from cufemlab_client import Client
client = Client(api_key=os.environ["CUFEMLAB_API_KEY"])
job = client.submit_job(
analysis_type="iron_loss_estimate",
input_params={"frequency_hz": 50.0, "flux_density_t": 1.5},
max_minutes=15,
)
res = client.wait(job.id)
print(f"loss={res.value} W/kg ref={res.reference}")
04 — Signed PDF report
import os
from cufemlab_client import Client
client = Client(api_key=os.environ["CUFEMLAB_API_KEY"])
source_job_id = "..." # a completed job whose result you want to certify
job = client.submit_job(
analysis_type="signed_report_generation",
input_params={"source_job_id": source_job_id, "format": "pdf"},
max_minutes=5,
)
client.wait(job.id)
client.download_report(job.id, out_path="report.pdf")
Snippets call only the public
/api/v1/* surface; no proprietary
internals are exposed.