Skip to content

Simulations & Solvers

FDTD, Low-Frequency, Neuron, Mode-Matching, Flow, Acoustics, etc...

228 Topics 673 Posts

Subcategories


  • FDTD, Low-Frequency, Neuron, Mode-Matching, Flow, Acoustics, etc...

    11 Topics
    27 Posts
    N

    Hi! Can someone help me understand if it makes sense to calculate SAR statistics in a low frequency electrical stimulation (30 Hz)? Thanks!!

  • The SAR values are greatly different for the Gaussian and sine waveforms

    8
    0 Votes
    8 Posts
    633 Views
    W

    @Sylvain Thank you for you reply. I think I have known the explaination. Actually, I want use the EM FDTD and the Thermal Transient modules to simulate the heating problem. Firstly, I used the sine waveform as the excitation signal. The microwave induced heat caused significant temperature increasing. However, when I replaced the continuous sine waveform into the waveform with pulse width modulation (the duty cycle is 10%), it doesn't see temperature increasing any more. I noticed that I didn't select the option of normalization in the source of Thermal Transient. I don't knwo whether I should select the normalization and set the scale factor as 1 W? The normal sine waveform and the modulated sine waveform are shown in below, respectively.
    捕获2.PNG
    捕获1.PNG

  • Transducer Array

    4
    0 Votes
    4 Posts
    328 Views
    M

    Yes I'm aware of what you're referring to but there is no readily available template available in Sim4Life. With some work it could be easily generated via a Python script (by creating spheres and disks and using boolean operators to intersect or subtract them) or perhaps you can maybe email the S4L support team to ask if they can provide you with a model for you to import?

  • GPU simulation - Error code (no error code)

    2
    0 Votes
    2 Posts
    240 Views
    ofliO

    Hi,

    Did you try to run one of the tutorial examples (Dipole antenna, for example) with CUDA solver? How big is your simulation project in terms of grid size?

  • Thermal Simulation, Surface normals not found warning

    Solved
    4
    1 Votes
    4 Posts
    367 Views
    J

    I am having this issue as well, with S4L Light 5.2.1.1375 which is the latest version(as of the time I am posting this). My model is simple cylinder with homogenous liquid modeled within the S4L software platform. Any advice or insight how to remove it would be much appreciated as it means I cannot run the solver as it diverges.

    Note: This was fixed by removing the nan's from my source term, and surrounding my cylindeer with a rectangular block of air so that the solver was working in a rectangular black not a cylinder.

  • FDTD Timestep

    2
    0 Votes
    2 Posts
    291 Views
    M

    Hi,
    As FDTD is a time-domain based method, implementing LF sources with this method is quite challenging. It would need a very (very) long simulation's time, without any assurance of reaching the correct convergence level at the end - furthermore if your simulation has a certain amount of MCells.
    For input signal with frequency components below the MHz, LF approach is the only solution that would give you quick and accurate results. I would thus advice you to (1) get the current profile along time, and (2) do a fft so as to get the current's magnitude for each of the frequency components. Then, (3) perform several LF simulations for each of the frequency/magnitude obtained during step (2).
    Best

  • Maximum Cell Count

    10
    0 Votes
    10 Posts
    848 Views
    J

    thanks. It works if I lower it to 55khz, but not if I lower it to 2kHz.

  • Material anisotropy along a curve?

    4
    0 Votes
    4 Posts
    393 Views
    M

    Something to get started to create an anisotropic conductivity tensor for S4L from solving a Poisson equation with boundary conditions (running an EM simulation and using its potential). Once the field is created in the analysis tab it can be used as a part of a new EM simulation for any material selected to have inhomogeneous and anisotropic properties.

    import numpy as np import s4l_v1.document as document import s4l_v1.model as model import s4l_v1.simulation.emlf as emlf from s4l_v1 import ReleaseVersion, Unit from s4l_v1.model import Vec3, Translation, Rotation import s4l_v1.units as units import s4l_v1.analysis as analysis import XCoreModeling def CreateMockAnisotropicConductivity(sim): # Transversal and longitudinal sigmas sigma1 = 3.0 sigma2 = 1.0 # here conductivity has 6 component (anisotropic tensor) results = sim.Results() p = results["Overall Field"].Outputs["EM Potential(x,y,z,f0)"] p.Update() e = results["Overall Field"].Outputs["EM E(x,y,z,f0)"] e.Update() e_field = e.Data.Field(0) nc = e.Data.Grid.NumberOfCells print "E Field shape", e_field.shape print "Number of Cells", nc # E Field shape (nc, 3) - Cell centered # Calculate sigma on cell centers print "Calculate anisotropic sigma values" sigma_wm = np.zeros([nc,6]) # 6 unique values # tensor component indexing for solver iu3 = (np.array([0, 1, 2, 0, 1, 0], dtype=np.int64), np.array([0, 1, 2, 1, 2, 2], dtype=np.int64)) for idx, val in enumerate(e_field): tmp = np.zeros([3,3], dtype=np.complex) tmp[0] = val if (not np.isnan(val).any() and np.inner(val, val) != 0): P = np.dot(tmp.T, tmp) / np.inner(val,val) else: P = np.full((3, 3), 0, dtype=np.complex) sigma_tensor = sigma1*P + sigma2*( np.identity(P.shape[0]) - P ) sigma_wm[idx] = sigma_tensor[iu3].real sigma_swapped = sigma_wm[:,[0,1,2,3,5,4]] # Fix bug where yz and xz were swapped tensor_conductivity = analysis.core.DoubleFieldData() tensor_conductivity.NumberOfSnapshots = 1 tensor_conductivity.NumberOfComponents = 6 tensor_conductivity.Grid = e.Data.Grid.Clone() tensor_conductivity.ValueLocation = analysis.core.eValueLocation.kCellCenter tensor_conductivity.SetField(0, sigma_swapped) #sigma_wm) # Fix bug where yz and xz were swapped tensor_conductivity.Quantity.Name = 'Anisotropic Conductivity From E Field' tensor_conductivity.Quantity.Unit = analysis.core.Unit('S/m') producer_t = analysis.core.TrivialProducer() producer_t.SetDataObject(tensor_conductivity) producer_t.Name = 'Anisotropic Conductivity' document.AllAlgorithms.Add(producer_t)
  • Inhomogenous anisotropic electrical conductivity

    6
    0 Votes
    6 Posts
    605 Views
    M

    @montanaro said in Inhomogenous anisotropic electrical conductivity:

    Hi yes this is possible in the latest release of Sim4Life, however there isn't a good tutorial for it at the moment (I'll help prepare one). Essentially what is needed is to create a Trivial Producer (an artificial field distribution in the Analysis tab) via Python that has 6 components, representing the symmetric anisotropic tensor values ordered in such a way: xx, yy, zz, xy, xz, yz. Each component should have the full anisotropic values that will be interpolated into the simulation grid. This trivial producer must be assigned the correct units of S/m (this is all handled via a Python script). Once that is done, then in your EM simulation you can assign these values to any given material: Materials -> Electric Conductivity: Anisotropic, Inhomogeneous -> Data Origin: Analysis Output -> Then you can select your field.

    I'll hopefully find some time to update this comment here with a sample script.

    Here's a sample script I found to import VTI data and convert it to a Trivial producer in the correct format. Let me know if anything is not clear.

    # -*- coding: utf-8 -*- import os import numpy as np import vtk from vtk.numpy_interface import dataset_adapter as dsa import XCoreModeling import XPostProcessor fp = r"D:\Users\sample\path" fn = "sample.vti" f = os.path.join(fp, fn) reader = vtk.vtkXMLImageDataReader() reader.SetFileName(f) reader.Update() img = dsa.WrapDataObject(reader.GetOutput()) dxx = img.PointData['Dxx'] dyy = img.PointData['Dyy'] dzz = img.PointData['Dzz'] dxy = img.PointData['Dxy'] dyz = img.PointData['Dyz'] dxz = img.PointData['Dxz'] dims = img.VTKObject.GetDimensions() origin = img.VTKObject.GetOrigin() spacing = img.VTKObject.GetSpacing() # scale to meters scale = XCoreModeling.GetActiveModel().LengthUnits.ToUnit(XPostProcessor.Unit.Meter) origin = [scale*origin[0], scale*origin[1], scale*origin[2]] spacing = [scale*spacing[0], scale*spacing[1], scale*spacing[2]] grid = XPostProcessor.UniformGrid() grid.SetUnit(0, XPostProcessor.Unit.Meter) # note meters here grid.SetUnit(1, XPostProcessor.Unit.Meter) grid.SetUnit(2, XPostProcessor.Unit.Meter) # create dual grid, so we can assign point data from image as cell centered data grid.SetDimensions(dims[0]+1, dims[1]+1, dims[2]+1) grid.SetOrigin(origin[0]-0.5*spacing[0], origin[1]-0.5*spacing[0], origin[2]-0.5*spacing[0]) grid.SetSpacing(spacing[0], spacing[1], spacing[2]) assert grid.NumberOfCells == dxx.shape[0] sigma = np.zeros([grid.NumberOfCells,6]) sigma[:,0] = dxx sigma[:,1] = dyy sigma[:,2] = dzz sigma[:,3] = dxy sigma[:,4] = dyz sigma[:,5] = dxz aniso_cond = XPostProcessor.DoubleFieldData() aniso_cond.Grid = grid aniso_cond.NumberOfSnapshots = 1 aniso_cond.NumberOfComponents = 6 aniso_cond.ValueLocation = XPostProcessor.eValueLocation.kCellCenter aniso_cond.SetComponentLabel(0, "Dxx") aniso_cond.SetComponentLabel(1, "Dyy") aniso_cond.SetComponentLabel(2, "Dzz") aniso_cond.SetComponentLabel(3, "Dxy") aniso_cond.SetComponentLabel(4, "Dyz") aniso_cond.SetComponentLabel(5, "Dxz") aniso_cond.SetField(0, sigma) aniso_cond.Quantity.Name = 'Anisotropic Conductivity From DTI (use for Bone)' aniso_cond.Quantity.Unit = XPostProcessor.Unit('S/m') producer_t = XPostProcessor.TrivialProducer() producer_t.SetDataObject(aniso_cond) producer_t.Description = 'Anisotropic Conductivity' XPostProcessor.AlgorithmRegistry().AddAlgorithm(producer_t)
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Multidomain mesh not shown in mesh tools

    3
    0 Votes
    3 Posts
    423 Views
    C

    The multidomain mesh is currently not available for Sim4Life light, that's why the relevant button does not appear in the ribbon.

  • Using Multiple GPUs does not improve simulation time

    1
    0 Votes
    1 Posts
    232 Views
    No one has replied
  • Linear system solver could not determine the solution

    1
    0 Votes
    1 Posts
    311 Views
    No one has replied
  • Choosing current instead of voltage in electrodes

    1
    1 Votes
    1 Posts
    226 Views
    No one has replied
  • Voxel-wise initial conditions for Thermal Simulations

    2
    0 Votes
    2 Posts
    357 Views
    M

    Hi,
    In transient thermal simulation, several ways of defining initial temperatures distribution are available (as detailed in the Manual, section 2.8.2.5). In your case, either 'steady state' or 'continue simulation' can allow you to avoid those 30 min with no EM sources. Here an example of process:
    (1) Run a first thermal simulation with only the human model and its proper thermal features, until reaching the required steady-state. This simulation would be the initialization of all your thermal simulations.
    (2) Create a 2nd simulation in which the 'Material' is defined as for the first one and use the 'Continue Simulation' option. You would also need to define the 'Snapshot', meaning at what time of the first simulation you are considering the initial temperatures (take care in case of non-convergence). EM sources can then be directly applied at 0 second.
    For ensuring accuracy, I would advice you to keep the same grid for all your thermal simulations.
    Best,
    Mélina

  • Break of continuity on E-field

    1
    0 Votes
    1 Posts
    181 Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    125 Views
    No one has replied
  • Thermal simulation with linear perfusion parameters

    1
    0 Votes
    1 Posts
    220 Views
    No one has replied
  • Calibration for Edge ports and sources?

    1
    0 Votes
    1 Posts
    231 Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Nuerosimulation

    2
    0 Votes
    2 Posts
    1k Views
    AntoninoMCA

    Dear Farima,
    you can use Python scripts to do that quickly and precisely. The first thing to do is to write a script that sample N=100 (x,y) coordinates within the radius of the cylinder according to a distribution that you want (random, uniform, etc.). Then you can create trajectories as polylines for each sampled point. Something like that:

    import s4l_v1 as s4l import numpy as np from s4l_v1 import Vec3 R=10 # Radius (mm) Z=100 # length of the cylinder (mm) N=100 # N axons ## Creates a folder in the Model Panel folder=s4l.model.CreateGroup('Axon Trajectories') points=[] cnt=0 while cnt<N: # Creates Randomly Distributed Points x=2*R*(-0.5+np.random.rand()); y=2*R*(-0.5+np.random.rand()) if (x*x+y*y<R*R): axon=s4l.model.CreatePolyLine([Vec3(x,y,-0.5*Z),Vec3(x,y,+0.5*Z)]) axon.Name='Axon_'+str(cnt) folder.Add(axon) cnt+=1