Skip to main content

CENOS Python package

This is a simple package that allows to interface with the cenos backend via a python API.

Quick-start

To use this package you will need:

  • Python (> 3.10)
  • CENOS simulation software installed.

Once you have those, you can install this package:

pip install cenos-py

How it works

While you use CENOS normally using the GUI, most of your actions are written out to a python_trace_script.py file inside of the case itself (File -> Show case in file explorer). It will look something like this:

from cenos_py import CenosCase, setCenosLocation

setCenosLocation(r"C:\source\cenos")

case = CenosCase("INDUCTION")
case.set_pre_processor('geomWizard', load_recent=True)
case.update_template_shape_type(1, 'workpieceTube')
case.update_template_property(1, 'diameter3', 32)
case.update_template_property(1, 'diameter4', 10)
case.update_tab_property('simulation', 'tend', 3)
case.update_tab_property('simulation', 'isAdaptive', True)
case.assign_group_material('workpiece', 'alloy_34Cr4')
case.update_physics_property('physicsThermal', 'boundary', 'workpiece_surface', 'hr', 0.9)
case.entered_meshing_window()
case.set_meshing_global_density('rough')
case.set_meshing_grading_surface(0.29)
case.set_meshing_domain_element_size('workpiece', 2)
case.set_meshing_domain_skin_layer('workpiece', True, 4.6, 10, 1.4)
case.generate_mesh()
case.calculate()

This trace file is also the best reference for the API: if you're not sure which function to call to change something, make that change once in the GUI and check what got added to the trace file.

How to use it

[!IMPORTANT] Before running a trace script, move it out of the case folder. The case keeps writing to that file while it works, so running the script from inside it can cause the script to be modified while it's still running.

Let's look at two ways to run a case with different parameters.

Option 1: Build the whole case from scratch

The most obvious approach is to take the trace file and turn the parameter you care about into a variable, then repeat the whole thing in a loop:

from cenos_py import CenosCase, setCenosLocation

setCenosLocation(r"C:\source\cenos")

case = CenosCase("INDUCTION")

for i in [20, 30, 40, 50]:
    case.set_pre_processor('geomWizard', load_recent=True)
    case.update_template_shape_type(1, 'workpieceTube')
    case.update_template_property(1, 'diameter3', i)  # <-- parameter goes here
    case.update_template_property(1, 'diameter4', 10)
    case.update_tab_property('simulation', 'tend', 3)
    case.update_tab_property('simulation', 'isAdaptive', True)
    case.assign_group_material('workpiece', 'alloy_34Cr4')
    case.update_physics_property('physicsThermal', 'boundary', 'workpiece_surface', 'hr', 0.9)
    case.entered_meshing_window()
    case.set_meshing_global_density('rough')
    case.set_meshing_grading_surface(0.29)
    case.set_meshing_domain_element_size('workpiece', 2)
    case.set_meshing_domain_skin_layer('workpiece', True, 4.6, 10, 1.4)
    case.generate_mesh()
    case.calculate()

This works, but for a large case the script gets long, and it's easy to end up repeating steps that didn't actually need to change (like generating the mesh multiple times).

Option 2 (recommended): Open an existing case and only change what you need

Instead, you can open a case you've already built in the GUI, and only touch the properties you actually want to vary:

from cenos_py import CenosCase, setCenosLocation

setCenosLocation(r"C:\Users\user\AppData\Local\Programs\CENOS Induction Heating beta")

case = CenosCase("INDUCTION")

your_case_path = r"C:\Users\rp\CENOS\your_case"

for i in [20, 30, 40, 50]:
    case.open(your_case_path)

    # Create a copy first, so we don't overwrite the original case
    case.save_case_as(rf"C:\Users\rp\CENOS\your_case_{i}")

    case.update_template_property(1, "workpiece_height", i)
    case.calculate()

[!NOTE]
case.save_case_as(...) is called right after opening the case, before anything is changed. This saves a copy under a new name, so the base case stays untouched and each loop iteration produces its own separate case file.

This is the recommended approach: shorter scripts, and no wasted steps.

It also makes the base case easy to keep up to date. If you want to make a static, non-parametric change — a different material, a physics property, swapped-out geometry — just open your_case_path in the GUI, make the change, save it, and re-run your script. There's no need to touch the Python at all; every run will pick up the new base case automatically.

Result analysis

Actions performed in the CENOS GUI result viewer do not get written to the python trace script. Instead you can access all the results via case.results., for example:

case = cenos_py.CenosCaseIH()

case.open("C:/path/to/your/case")

case.results.get_active_power()
case.results.get_average_temperature("workpiece")

Each of the functions will have docstrings and argument and return type annotations, meaning if you start typing case.results.get_dielec then you should see the "parameter hints":

def get_dielectric_losses(
    entity: str = "Total",
    port: int = 1
) -> list[float]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cenos_py-0.2.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cenos_py-0.2.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file cenos_py-0.2.0.tar.gz.

File metadata

  • Download URL: cenos_py-0.2.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cenos_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5046a808cd16797e95bfe8dc5903bdc9f79289ecbe426f126b4a6be9a36833e2
MD5 74b1e315ee4fdfd38594e733ea5ddac4
BLAKE2b-256 e116e83a6f0177a61e4b4de19f8eb50475c0148f40ce514a955df0969b52bc11

See more details on using hashes here.

Provenance

The following attestation bundles were made for cenos_py-0.2.0.tar.gz:

Publisher: release.yaml on CENOS-Platform/cenos-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cenos_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cenos_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cenos_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19ee450d2061b5fdb0ce9cb96becba1718aee4a774eff4b288c2b01ea861fe01
MD5 bda645e8e7094128d722ad898c8efd25
BLAKE2b-256 ae6b4d5493aea728ae3ccd975574772e0cfdcf49336a82271dfef21c131d6146

See more details on using hashes here.

Provenance

The following attestation bundles were made for cenos_py-0.2.0-py3-none-any.whl:

Publisher: release.yaml on CENOS-Platform/cenos-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page