• Export spline points

    CAD Modeling
    3
    0 Votes
    3 Posts
    224 Views

    That worked- thanks a lot!

  • 1 Votes
    1 Posts
    148 Views
    No one has replied
  • 0 Votes
    5 Posts
    385 Views

    Mesh_material = sim.AddMaterialSettings(themesh(fromstl))
    Mesh_material.Name = yourname
    Mesh_material.ElectricProps.Conductivity = v # S/m

  • 2 Votes
    1 Posts
    161 Views
    No one has replied
  • 1 Votes
    3 Posts
    305 Views

    Perfect thanks !!

  • VSCode extension

    Python API
    5
    1 Votes
    5 Posts
    544 Views

    I am not sure to be honest why that was an issue for me with that specific version only, I installed the new version and it was there so problem solved!

  • 1 Votes
    2 Posts
    223 Views

    In general, an easy way to create a postprocessing script is to first do it in the GUI and then use the "To-Python" function (available via right-click on the algorithm in the Explorer window).

    Here is what the auto-generated script looks like for a simple pipeline with a Crop Filter:

    # Creating the analysis pipeline # Adding a new SimulationExtractor simulation = document.AllSimulations["EM"] simulation_extractor = simulation.Results() # Adding a new EmSensorExtractor em_sensor_extractor = simulation_extractor["Overall Field"] em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All" em_sensor_extractor.Normalization.Normalize = True em_sensor_extractor.SurfaceCurrent.SurfaceResolution = 0.001, units.Meters document.AllAlgorithms.Add(em_sensor_extractor) # Adding a new FieldCropFilter inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]] field_crop_filter = analysis.core.FieldCropFilter(inputs=inputs) field_crop_filter.LowerExtent = numpy.array([1, 3, 2]) field_crop_filter.UpperExtent = numpy.array([21, 21, 21]) field_crop_filter.UpdateAttributes() document.AllAlgorithms.Add(field_crop_filter)

    Note fyi that you don't actually need to pass a Numpy array to UpperExtent or LowerExtent, it also works if you pass any iterable, like a list or a tuple.

  • 0 Votes
    2 Posts
    375 Views

    This is common. Once you import a script, it becomes cached so even if you make changes to it and save it, python won't see the changes. You need to reload it as you said if you make changes to the imported script after running your main script.

  • 0 Votes
    2 Posts
    623 Views

    This looks quite good, thank you for providing your scripts.
    Note that, for the second method, you could create your cylinder directly at the desired position:

    cylinder2 = model.CreateSolidCylinder(Vec3(0,1,-15),Vec3(0,1,-15),0.5)

    There is also the XCoredModeling.CoverWires() function that allows you to make a surface (i.e. face) out of a circle entity.

    Last, but not least, note that the line model_to_grid_filter.MaximumEdgeLength is ultimately what determines the tradeoff between accuracy and computational cost of the interpolation (since it defines the resolution of the triangulated mesh on which the interpolation is done).

  • 3 Votes
    1 Posts
    507 Views
    No one has replied
  • 0 Votes
    1 Posts
    449 Views
    No one has replied
  • 1 Votes
    1 Posts
    453 Views
    No one has replied
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 1 Votes
    2 Posts
    519 Views

    Works perfectly, thanks!

    Edit,
    I think you could also get away with:

    import s4l_v1.model as model import XCoreModeling def get_spline_length(spline): wire = XCoreModeling.GetWires(spline)[0] return wire.GetLength()
  • 1 Votes
    2 Posts
    446 Views

    The gridding algorithms are quite different in V17 compared to V14.8, so many options simply do not have a one-to-one conversion. The best strategy is probably to learn how to use the gridder in the GUI of SEMCAD 17 (in particular the Manual Grid Settings) and then use the "To-Python" function to auto-generate the corresponding Python scripts.

    I don't know V14.8 well enough to answer your other questions from the top of my head and my current V14.8 installation is acting up, so I can't help with your other questions right now. I will as soon as I fix my setup!

  • 0 Votes
    2 Posts
    252 Views

    I had a look but also did not find it, so I added a function ConvertToPolyline which will become available in the next release (you can test it internally next week).

  • 0 Votes
    1 Posts
    371 Views
    No one has replied
  • 0 Votes
    1 Posts
    404 Views
    No one has replied
  • 2 Votes
    3 Posts
    804 Views

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

    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.