Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. A list of useful Sim4Life Python API snippets in a real project

A list of useful Sim4Life Python API snippets in a real project

Scheduled Pinned Locked Moved Python API
1 Posts 1 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Robin WydaegheR Offline
    Robin WydaegheR Offline
    Robin Wydaeghe
    wrote last edited by
    #1

    Hello there,

    I made a coding project where I used the Sim4Life Python API quite a bit, check it out! I figured that a list of all the places it interfaces Sim4Life would be useful to the community: https://rwydaegh.github.io/goliat/reference/useful_s4l_snippets/

    Pasting only the questions here so Google crawlers can find it, while keeping this post not too long!

    1. Application control
    
    How can I start the Sim4Life application programmatically?
    
    How can I suppress Sim4Life logging output?
    
    2. Project management
    
    How can I create a new Sim4Life project?
    
    How can I open an existing Sim4Life project file?
    
    How can I save a Sim4Life project?
    
    How can I close a Sim4Life project?
    
    How can I get the current project file path?
    
    How can I access all simulations in a project?
    
    3. Model and geometry
    
    How can I get all entities in the model?
    
    How can I get the bounding box of entities?
    
    How can I create geometric entities?
    
    How can I import models from files?
    
    How can I export entities to files?
    
    How can I transform entities (translate, rotate, scale)?
    
    How can I calculate distance between entities?
    
    How can I delete entities?
    
    How can I create Vec3 vectors?
    
    How can I identify and work with entity groups?
    
    How can I access child entities in a group?
    
    How can I decompose a transform into rotation and translation?
    
    4. Materials
    
    How can I access the material database?
    
    How can I link a material from the database to a simulation?
    
    How can I access material properties?
    
    How can I update material properties after frequency changes?
    
    5. Simulation setup
    
    How can I create an EM-FDTD simulation?
    
    How can I configure solver settings (kernel, etc.)?
    
    How can I set simulation time and termination criteria?
    
    How can I add an edge source (antenna excitation)?
    
    How can I add a plane wave source (far-field)?
    
    How can I add sensors (edge, point, far-field)?
    
    How can I configure automatic gridding?
    
    How can I configure manual gridding?
    
    How can I configure subgridding?
    
    How can I configure grid padding?
    
    How can I configure boundary conditions (PML)?
    
    How can I add voxeler settings and create voxels?
    
    6. Simulation execution
    
    How can I write the solver input file?
    
    How can I run a simulation locally?
    
    How can I run iSolve.exe manually?
    
    How can I submit a simulation to oSPARC cloud?
    
    How can I get the input file name from a simulation?
    
    7. Results extraction
    
    How can I access simulation results?
    
    How can I use E-field data as input to analysis algorithms?
    
    How can I extract SAR statistics?
    
    How can I extract peak SAR location details?
    
    How can I extract input power?
    
    How can I extract power balance?
    
    How can I extract point sensor data?
    
    8. Data and downloads
    
    How can I get available model downloads?
    
    How can I download a model?
    
    9. Analysis algorithms
    
    How can I add an algorithm to the document?
    
    How can I remove an algorithm from the document?
    
    How can I access algorithm outputs?
    
    How can I access all simulation settings?
    
    How can I set frequency extraction settings?
    
    10. Rendering and UI
    
    How can I set the view direction?
    
    How can I zoom to an entity?
    
    How can I capture a screenshot?
    
    How can I change the current UI mode?
    
    How can I control entity visibility?
    

    The introduction of the full PythonAPIReference that ships with Sim4Life v8.2+ was a big help and I invite you to look there, or to use the To Python function. The tutorials also cover a lot, but I hope that these snippets can cover some of the leftover gaps when it comes to real-world examples.

    Feel free to contact me if there are mistakes, or open an issue. Happy coding!

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Search