[S8626] Script for setting skin depth based on material and frequency

 

The following is an example of a script for setting the skin depth based on material and frequency.

import math

# Part name for which you want to set the skin depth

PartName = u"coil"

# Relative permeability of the component for which you want to set the skin depth

RP = 1

app = designer.GetApplication()

# Get the currently open study

study = app.GetCurrentStudy()

# Get the start frequency of the frequency interval for frequency control

frq = study.GetStep().GetValue(u"Initialfrequency")

# Get the electrical resistivity for the part

resistivity = study.GetMaterial(PartName).GetValue(u"Resistivity")

# Calculate skin depth

skin_depth = 1e3 * 1 / math.sqrt((1 / resistivity) * (math.pi * frq) * (RP*4 * math.pi * 1e-7))

# Create a skin depth mesh condition

study.GetMeshControl().CreateCondition(u"SkinDepth", f"Skin_{PartName}")

# Set condition parameters

condition = study.GetMeshControl().GetCondition(f"Skin_{PartName}")

condition.SetValue("Depth", skin_depth * 2)

condition.SetValue("Division", 3)

# Clear Selected Parts

condition.ClearParts()

# Select parts

sel = condition.GetSelection()

sel.SelectPart(PartName)

# Add selected parts as conditions

condition.AddSelected(sel)

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.