How to Change Material Properties with Python?
-
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?

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/2Thank you!
-
D dbsim4 marked this topic as a question on
-
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
-
Mesh_material = sim.AddMaterialSettings(themesh(fromstl))
Mesh_material.Name = yourname
Mesh_material.ElectricProps.Conductivity = v # S/m -
S Sylvain has marked this topic as solved on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login