Change material properties from script


I’m trying to fully script the tutorial example “p-n Junction Diode” found here:

I get to the point where I want to simplify the silicon material properties to get the “ideal” diode characteristics. However, I can’t figure out how to programmatically change the material properties.

I tried using the setmaterial() command from here:
but it doesn’t seem to work:

?setmaterial("Si (Silicon)"); color

I expected ?setmaterial("Si (Silicon)"); to return all of the modifiable properties of silicon as I see them when I click Materials -> Si (Silicon) in the GUI. What am I doing wrong?



Hi. Unfortunately the DEVICE material database does not provide access to the material properties through scripting. The “setmaterial” command is only available in the optical solvers. If you would like to use script for the “pn junction diode” example, the only workaround would be to create the three materials (‘si-ideal’, ‘si-bulk’, and ‘si-bulk-surface’) beforehand and save them in the defaults file of DEVICE. You can then use the script to simply assign the different materials to the silicon geometry one at a time. While not perfect, this is probably the best solution right now.