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. Moving from SEMCAD 14.8 to Sim4Life python API

Moving from SEMCAD 14.8 to Sim4Life python API

Scheduled Pinned Locked Moved Python API
pythonsemcad
3 Posts 1 Posters 1.2k Views
  • 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.
  • pcrespoP Offline
    pcrespoP Offline
    pcrespo
    wrote on last edited by admin
    #1

    I am a user of SEMCAD 14.8 python API and I am adapting my scripts to Sim4Life python API.

    I have some questions:

    1. How can we synchronize the entities in a model with a simulation (say, s4l_v1.simulation.emfdtd.Simulation)? Previously, the SolidRegions in a simulation seemed to be synchronized with model entities automatically, but it seems that SolidRegions are not available in simulations anymore.
    2. Since SolidRegions are no longer available, is there any equivalent to this? Are materials the appropriate replacement?
    3. Is there a replacement available for the old model.IsSolid(entity)? Currently I’m checking to see if an entity has any faces, and if it does, I’m assuming that it is a solid, but this doesn’t seem like the correct way to do this.
    4. Are SEMCAD.SetModelingMode() and SEMCAD.SetSimulationMode() required anymore? If so, what are their replacements?
    5. In the old version, SEMCAD.simulations.GetActiveSimulation() could be called in a new document, and a simulation would be available. In the new version, it appears that there is no simulation present by default. Thus, is adding a simulation using s4l_v1.document.AllSimulations.Add(s4l_v1.simulation.emfdtd.Simulation()) the appropriate way to create a simulation? Is there anyway to have it be synchronized to the model automatically (see #1)?

    P.

    pcrespoP 1 Reply Last reply
    2
    • pcrespoP pcrespo

      I am a user of SEMCAD 14.8 python API and I am adapting my scripts to Sim4Life python API.

      I have some questions:

      1. How can we synchronize the entities in a model with a simulation (say, s4l_v1.simulation.emfdtd.Simulation)? Previously, the SolidRegions in a simulation seemed to be synchronized with model entities automatically, but it seems that SolidRegions are not available in simulations anymore.
      2. Since SolidRegions are no longer available, is there any equivalent to this? Are materials the appropriate replacement?
      3. Is there a replacement available for the old model.IsSolid(entity)? Currently I’m checking to see if an entity has any faces, and if it does, I’m assuming that it is a solid, but this doesn’t seem like the correct way to do this.
      4. Are SEMCAD.SetModelingMode() and SEMCAD.SetSimulationMode() required anymore? If so, what are their replacements?
      5. In the old version, SEMCAD.simulations.GetActiveSimulation() could be called in a new document, and a simulation would be available. In the new version, it appears that there is no simulation present by default. Thus, is adding a simulation using s4l_v1.document.AllSimulations.Add(s4l_v1.simulation.emfdtd.Simulation()) the appropriate way to create a simulation? Is there anyway to have it be synchronized to the model automatically (see #1)?
      pcrespoP Offline
      pcrespoP Offline
      pcrespo
      wrote on last edited by
      #2

      @pcrespo said in Moving from SEMCAD 14.8 to Sim4Life python API:

      1. Are SEMCAD.SetModelingMode() and SEMCAD.SetSimulationMode() required anymore? If so, what are their replacements?

      No these modes are not necessary anymore. Modeling, simulation and analysis coexist in the same environment without having to call any initialization routine as in SEMCAD 14.8

      The new paradigm is that your project is represented as a document

      import s4l_v1.document as project # this is a singleton
      
      project.New()
      

      you can add modeling entities, simulations and analysis algorithms to it. The model entities are added automatically (because we have a single model per project) while the simulations and the analysis algorithms need to be explicitly added,
      Every part is now separated in a different package:

      import s4l_v1.model as model
      import s4l_v1.simulation.emfdtd as fdtd
      import s4l_v1.analysis as analysis
      
      # ... can create some modeling .entities using model..
      
      # ... operations to create a new fdtd simulation ...
      
      project.AllSimulations.Add(new_simulation)
      
      # ... can create pipelines of algorithms ...
      
      project.AllAlgorithms.Add(new_algorithm)
      

      Adding simulation and algorithm instances to the S4L document, renders then automatically in the UI.

      P.

      1 Reply Last reply
      0
      • pcrespoP Offline
        pcrespoP Offline
        pcrespo
        wrote on last edited by
        #3

        @pcrespo said in Moving from SEMCAD 14.8 to Sim4Life python API:

        1. How can we synchronize the entities in a model with a simulation (say, s4l_v1.simulation.emfdtd.Simulation)? Previously, the SolidRegions in a simulation seemed to be synchronized with model entities automatically, but it seems that SolidRegions are not available in simulations anymore.

        Yes, the philosophy there changed a bit. The idea is that every context adds a new layer of information on top of the previous one. When the user starts modeling, it is expected to define the geometry of the problem. For instance, what is the shape, position and size of a given entity.

        The simulation context adds the necessary information to the geometry of the problem so that we can perform a numerical simulation. These new settings could be related with the physics of the problem (e.g. electric properties of a given geometry ) or with the numerical method (e.g. fdtd grid details for the discretization of a given geometry). Creating a simulation in the UI reveals what type of settings each simulation type adds on the associated modeling entities.

        Another big different with respect to SEMCAD is that every simulation uses a selection of entities instead of using by default all and having to unselect/ignore them. It has the same result but the producer is reversed.

        Then, coming back to the API, assume we want to simulate a dipole antenna.. To start I modeled two arms and a line to define the feed. I can retrieve them by name as follows:

                import s4l_v1.model as model
        
        	entities = model.AllEntities()
        
        	arm1 = entities['Arm 1']
        	arm2 = entities['Arm 2']
                line = entities['SourceLine']
        

        Now i want to create a simulation that uses this geometry. In order to assign a material to these entities, I need to
        a) associate the entities to the simulation (they become simulation components)
        b) create material settings and
        c) assign these settings to the associated entities.
        The API provides a shortcut for these three operations simulation.Add*Settings . This directly returns the settings object assigned to the entity within this simulation. Then we can set the values of the different properties:

         simulation = fdtd.Simulation()
        
        # ... some general settings ...
        
        # Materials:
        dipole_material = simulation.AddMaterialSettings([arm1, arm2])
        dipole_material.Name = 'Dipole Arms'
        dipole_material.MaterialType = dipole_material.MaterialType.enum.PEC
        
        

        and analogously with the line entity:

        	edgesrc_settings = sim.AddEdgeSourceSettings([line,])
        	options = edgesrc_settings.ExcitationType.enum
        	edgesrc_settings.ExcitationType = options.Gaussian
        	edgesrc_settings.CenterFrequency = 300., units.MHz
        	edgesrc_settings.Bandwidth = 300., units.MHz
        

        The model entity in a simulation and with all the extra layers is now referred as a simulation component. In other words, a simulation component is a geometry (defined by model entity) with several layers of settings corresponding to the physics and the numerical methods.

        P.

        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