• 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

How to Change Material Properties with Python?

Scheduled Pinned Locked Moved Unsolved Python API
emfdtdpythonmaterialpython api
5 Posts 4 Posters 299 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.
  • D Offline
    D Offline
    dbsim4
    wrote on last edited by dbsim4
    #1

    Hello,

    I'm trying to change EMFDTD material properties in a simulation that's already set up, using the VIP Body Models.

    If I change the conductivity value, it immediately resets itself to the original value - how do I get it to keep my new value?

    aa4df71a-f9d4-4fae-b942-ec638d650dea-image.png

    I'm getting "s" from this answer, to get the list of materials:
    https://forum.zmt.swiss/topic/16/how-to-update-material-settings-using-the-material-database-from-python/2

    Thank you!

    1 Reply Last reply
    0
  • D dbsim4 marked this topic as a question on
  • K Offline
    K Offline
    Konohana
    wrote on last edited by
    #2

    Hey there,
    I am not sure if this will fix your issue, but I can provide you with a piece of code that I used to apply material settings to the tissues in my simulations:

    # dictionary containing all tissue names and entities in the simulation:
    all_tissues_present = {}
    
    if 'Bone_cortical' in all_entities: 
    	print('Bone assigned')
    	entity_bone1 = all_entities["Bone_cortical"]
    	all_tissues_present["Bone_cortical"] = entity_bone1
    
    # Dictionary containing material properties such as conductivity
    tissue_conductivities = {
    	'Scalp': [0.439, 1], 
    	'Cerebrum_white_matter': [0.348, 10], 
    	'Cerebrum_grey_matter': [0.419, 9], 
    	'Cerebrospinal_fluid': [1.88, 8], 
    	'Bone_cortical': [0.00645, 3],
             }
    
    # Code to assign material settings to the correct tissues. Using the dictionaries above this can then be done in a for-loop:
    
    for tissue_name, tissue_entity in all_tissues_present.items():
         material_settings = emlf.MaterialSettings()
         components = [tissue_entity] 
         material_settings.Name = tissue_name
         material_settings.ElectricProps.Conductivity = 
         tissue_conductivities[tissue_name][0], Unit("S/m")		
         simulation.Add(material_settings, components)
    
    

    I hope this helps and wish you a very nice day.

    Best

    1 Reply Last reply
    2
  • D Offline
    D Offline
    dbsim4
    wrote on last edited by
    #3

    Thank you very much, this is really helpful!

    How do you access the initial "all_entities" list?

    I've tried

    import s4l_v1.model as model
    
    for e in model.AllEntities:
    	print(e)
    

    but I this error:

    TypeError: 'type' object is not iterable
    
    1 Reply Last reply
    0
  • B Online
    B Online
    bryn
    wrote on last edited by
    #4

    try for e in model.AllEntities():

    1 Reply Last reply
    0
  • M Offline
    M Offline
    michaelsch
    wrote on last edited by
    #5

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

    1 Reply Last reply
    0

  • Login

  • Don't have an account? Register

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