{"sections":[{"heading":"Before starting","paragraphs":["Matching compiled Python module/interpreter, valid licence and complete writable circuit/dependencies"]},{"heading":"Steps","steps":["Use the compiled josimpro module from the intended installation and a compatible Python environment. The supplied install helper creates a user-site .pth entry; custom layouts can use PYTHONPATH.","Inspect jp.VERSION, jp.BUILD_TIMESTAMP and jp.GIT_HASH, and use jp.core_identity_json() when you need the actually loaded core identity. The 2.9 version label alone does not identify a particular module/core payload.","Configure the issued licence path through jp.Settings.license when the default is unsuitable; never embed licence contents in a script or report.","Load a copied complete circuit using Input, construct Matrix, validate simulation readiness and execute Simulation as below.","Check sim.isSimOK, run feedback and the requested outputs before consuming numerical results."]},{"code":"import os\nimport sys\nfrom pathlib import Path\n\n# Windows default install: this changes only the current Python process.\nif os.name == \"nt\":\n    bin_dir = Path(os.environ[\"ProgramFiles\"]) / \"SUN Magnetics\" / \"JoSIM-Pro\" / \"bin\"\n    dll_directory = os.add_dll_directory(str(bin_dir))\n    sys.path.insert(0, str(bin_dir))\n\nimport josimpro as jp\n\nprint(jp.VERSION, jp.BUILD_TIMESTAMP, jp.GIT_HASH)\n# Set jp.Settings.license to your issued licence path if required.\ninp = jp.Input(\"JTL_Example.cir\")\nmat = jp.Matrix(inp)\nmat.validate_simulation_ready()\nsim = jp.Simulation(mat)\nsim.simulate(mat)\nprint(\"Simulation OK:\", sim.isSimOK)\nprint(\"Accepted steps:\", sim.stepCount)","heading":"Documented example"},{"heading":"Check the result","paragraphs":["The loaded module is the intended build, readiness succeeds and sim.isSimOK reports success for the intended circuit.","VAL-012 exercised the documented file-based run on the recorded Windows review module. Other interpreter/platform combinations, final-package applicability and physical accuracy remain to be checked."]},{"heading":"If the problem remains","paragraphs":["If import fails, check the interpreter compatibility and module directory. If simulation fails, retain the traceback and relevant diagnostic, then check the same circuit/dependencies with the matching CLI."]}],"canonical_url":"https://www.sun-magnetics.com/knowledge-base/josim-python-first-run","url":"/knowledge-base/josim-python-first-run","known_issues":[],"search_record":{"execution":true,"relatedProducts":[],"version_tags":["JoSIM-Pro 2.9 target"],"text":"Run a circuit from Python with josimpro Make the matching josimpro extension importable, construct Input and Matrix from a saved circuit, validate readiness and execute Simulation. JoSIM-Pro 2.9.0 release target; source-documentation evidence How to python josimpro module import api agent simulation first run getting started Before starting Matching compiled Python module/interpreter, valid licence and complete writable circuit/dependencies  Steps Use the compiled josimpro module from the intended installation and a compatible Python environment. The supplied install helper creates a user-site .pth entry; custom layouts can use PYTHONPATH. Inspect jp.VERSION, jp.BUILD_TIMESTAMP and jp.GIT_HASH, and use jp.core_identity_json() when you need the actually loaded core identity. The 2.9 version label alone does not identify a particular module/core payload. Configure the issued licence path through jp.Settings.license when the default is unsuitable; never embed licence contents in a script or report. Load a copied complete circuit using Input, construct Matrix, validate simulation readiness and execute Simulation as below. Check sim.isSimOK, run feedback and the requested outputs before consuming numerical results.  Documented example import os\nimport sys\nfrom pathlib import Path\n\n# Windows default install: this changes only the current Python process.\nif os.name == \"nt\":\n    bin_dir = Path(os.environ[\"ProgramFiles\"]) / \"SUN Magnetics\" / \"JoSIM-Pro\" / \"bin\"\n    dll_directory = os.add_dll_directory(str(bin_dir))\n    sys.path.insert(0, str(bin_dir))\n\nimport josimpro as jp\n\nprint(jp.VERSION, jp.BUILD_TIMESTAMP, jp.GIT_HASH)\n# Set jp.Settings.license to your issued licence path if required.\ninp = jp.Input(\"JTL_Example.cir\")\nmat = jp.Matrix(inp)\nmat.validate_simulation_ready()\nsim = jp.Simulation(mat)\nsim.simulate(mat)\nprint(\"Simulation OK:\", sim.isSimOK)\nprint(\"Accepted steps:\", sim.stepCount) Check the result The loaded module is the intended build, readiness succeeds and sim.isSimOK reports success for the intended circuit. VAL-012 exercised the documented file-based run on the recorded Windows review module. Other interpreter/platform combinations, final-package applicability and physical accuracy remain to be checked.  If the problem remains If import fails, check the interpreter compatibility and module directory. If simulation fails, retain the traceback and relevant diagnostic, then check the same circuit/dependencies with the matching CLI. ","id":"josim-python-first-run","keywords":"python josimpro module import api agent simulation first run getting started","kind":"How to","title":"Run a circuit from Python with josimpro","product":"JoSIM-Pro"},"version":"2.9.0 release target; source-documentation evidence","id":"josim-python-first-run","related":["/knowledge-base/josim-cli-output","/knowledge-base/josim-runtime-precedence","/knowledge-base/josim-licensing-unavailable"],"downloads":[],"publication_status":"published","numerical_output":null,"provenance":{"execution_checks":[{"routes":["cli","python-api"],"scope":"Packaged JTL through Python Input/Matrix/Simulation, raw and named arrays, formatted output axis and CSV writer; the same current CLI produced exactly matching parsed CSV","result":"passed","articles":["josim-first-jtl","josim-cli-output","josim-python-first-run","josim-api-output"],"purpose":"python-first-run-and-output","version":"JoSIM-Pro 2.9.0 Windows review runtime; CPython 3.13.11 and NumPy 2.5.4 in an isolated environment","id":"VAL-012","records":["python-jtl-first-run","python-parity-cli"],"limit":"Execution, finite data, shape/time coverage and same-engine interface agreement. No independent physical reference, convergence, GUI, other interpreter/platform or final-release qualification.","observed":{"named_csv_shape_and_time_coverage":true,"samples":1001,"time_start_seconds":0,"named_traces":4,"documented_first_run_completed":true,"raw_state_shape":[12,1001],"accepted_steps_reported":true,"installed_inputs_module_and_core_unchanged":true,"time_end_seconds":2.5e-10,"four_finite_named_trace_arrays":true,"formatted_axis_matches_named_trace_lengths":true,"cli_and_python_csv_exactly_agree":true,"raw_time_and_state_arrays":true,"intended_loaded_core":true,"intended_python_module":true}}],"figure_evidence":[],"review_notes":["The Windows process-local module/DLL search setup and file-based simulation were exercised without changing global Python or licence configuration. The default installation path must be adjusted for a custom install.","The installed module and loaded core identities were checked. This is one CPython/platform combination, not all Python or final-release qualification."],"scope":"Recorded inputs/builds only. Complete walkthrough and final-package acceptance remain separate.","verification_requirements":{"gui_method":"not-required-for-this-answer","status":"review-incomplete","illustrations":"not-required-for-this-answer","required":["technical-review","release-applicability","execution","numerical-interpretation"],"legacy_walkthrough_field":"pending retained; not evidence of a complete scenario"},"sources":[{"id":"josim-pro:docs/manual_source/sections/python.tex","section":"Making the module available; Process-wide settings and licensing; Smallest useful file-based run"},{"id":"owner:technical-review-20261102","section":"Owner selected 2.9 as the publication target; final package checks remain required"},{"id":"validation:windows-workflows-20261103","section":"VAL-011/VAL-012; exact route, runtime and evidence limits"}]},"title":"Run a circuit from Python with josimpro","type":"How to","markdown_url":"/_functions/kbResource?path=markdown%2Fjosim-python-first-run.md","summary":"Make the matching josimpro extension importable, construct Input and Matrix from a saved circuit, validate readiness and execute Simulation.","product":"JoSIM-Pro"}