Skip to content

Resolve "Create Solver class"

Lucas POLO-LOPEZ requested to merge 17-create-solver-class into develop

Closes #17 (closed)

Methods to implement

setFrequencyRange(self, fMin: Union[float, str], fMax: Union[float, str])

vba = 'Solver.FrequencyRange "{}", "{}"'.format(freqParams["fMin"], freqParams["fMax"])

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define frequency range", vba)

getSolverType(self)

No input parameters

result = self.__MWS.GetSolverType()

changeSolverType(self, type: str)

Valid values for type: "HF Time Domain", "HF Eigenmode", "HF Frequency Domain", "HF IntegralEq", "HF Multilayer", "HF Asymptotic".

vba = 'ChangeSolverType "{}"'.format(type)

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("change solver type", vba)

setBoundaryCondition(self, xMin: str, xMax: str, yMin: str, yMax: str, zMin: str, zMax: str, wallCond: Union[float, str] = 1000.0)

# Generate the VBA code for defining the boundary conditions
allBoundaries = {xMin, xMax, yMin, yMax, zMin, zMax}

if "expand open" in allBoundaries:
    addSpaceFactorVBA = '.OpenAddSpaceFactor "0.5"\n'
else:
    addSpaceFactorVBA = ""

if "conducting wall" in allBoundaries:
    wallCondVBA = '.WallConductivity "{:f}"\n'.format(wallCond)
else:
    wallCondVBA = ""

vba = (
    'With Boundary\n' +
    '.Xmin "{}"\n'.format(xMin) +
    '.Xmax "{}"\n'.format(xMax) +
    '.Ymin "{}"\n'.format(yMin) +
    '.Ymax "{}"\n'.format(yMax) +
    '.Zmin "{}"\n'.format(zMin) +
    '.Zmax "{}"\n'.format(zMax) +
    '.ApplyInAllDirections "False"\n' +
    addSpaceFactorVBA +
    wallCondVBA +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define boundaries", vba)

addSymmetryPlane(self, xSym: str, ySym: str, zSym: str)

# Generate the VBA code for defining the symmetries

vba = (
    'With Boundary\n' +
    '.Xsymmetry "{}"\n'.format(xSym) +
    '.Ysymmetry "{}"\n'.format(ySym) +
    '.Zsymmetry "{}"\n'.format(zSym) +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define boundaries", vba)

addFieldMonitor(self, type: str, freq: Union[float, str])

Valid type values

# Generate the VBA code for creating the field monitor
name = type + ' (f={})'.format(monitorParams["freq"])
vba = (
    'With Monitor\n' +
    '.Reset\n' +
    '.Name "{}"\n'.format(name) +
    '.Dimension "Volume"\n' +
    '.Domain "Frequency"\n' +
    '.FieldType "{}"\n'.format(type) +
    '.Frequency "{}"\n'.format(monitorParams["freq"]) +
    '.UseSubVolume "False"\n' +
    '.Create\n' +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define monitor: " + name, vba)

setBackgroundMaterial(self, type: str, epsR: Union[float, str]=1.0, muR: Union[float, str]=1.0, tanD: Union[float, str]=0.0, tanDFreq: Union[float, str]=0.0, tanDGiven: bool=False, sigma: Union[float, str]=0.0, tanDM: Union[float, str]=0.0, tanDMFreq: Union[float, str]=0.0, tanDMGiven: bool=False, sigmaM: Union[float, str]=0.0)

# Generate the VBA code for defining the background material
if type == "Vacuum":
vba = (
    'With Material\n' +
    '.Type "Normal"\n' +
    '.Colour "0.6", "0.6", "0.6"\n' +
    '.Epsilon "1"\n' +
    '.Mu "1"\n' +
    '.sigma "0.0"\n' +
    '.sigmaM "0.0"\n' +
    '.TanDGiven "False"\n' +
    '.TanDMGiven "False"\n' +
    '.ChangeBackgroundMaterial\n' +
    'End With'
    )
elif type == "PEC":
vba = (
    'With Material\n' +
    '.Type "PEC"\n' +
    '.Colour "0.6", "0.6", "0.6"\n' +
    '.Epsilon "1"\n' +
    '.Mu "1"\n' +
    '.ChangeBackgroundMaterial\n' +
    'End With'
    )
else: # type == "Dielectric"
vba = (
    'With Material\n' +
    '.Type "Normal"\n' +
    '.Colour "0.6", "0.6", "0.6"\n' +
    '.Epsilon "{}"\n'.format(bkgrParams["epsR"]) +
    '.Mu "{}"\n'.format(bkgrParams["muR"]) +
    '.tand "{}"\n'.format(bkgrParams["tanD"]) +
    '.TanDFreq "{}"\n'.format(bkgrParams["tanDFreq"]) +
    '.TanDGiven "{}"\n'.format(tanDGiven) +
    '.sigma "{}"\n'.format(bkgrParams["sigma"]) +
    '.tandM "{}"\n'.format(bkgrParams["tanDM"]) +
    '.TanDMFreq "{}"\n'.format(bkgrParams["tanDMFreq"]) +
    '.TanDMGiven "{}"\n'.format(tanDMGiven) +
    '.sigmaM "{}"\n'.format(bkgrParams["sigmaM"]) +
    '.ChangeBackgroundMaterial\n' +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("set background material", vba)

setBackgroundLimits(self, xMin: Union[float, str], xMax: Union[float, str], yMin: Union[float, str], yMax: Union[float, str], zMin: Union[float, str], zMax: Union[float, str])

vba = (
    'With Background\n' +
    '.XminSpace "{}"\n'.format(bkgParams["xMin"]) +
    '.XmaxSpace "{}"\n'.format(bkgParams["xMax"]) +
    '.YminSpace "{}"\n'.format(bkgParams["yMin"]) +
    '.YmaxSpace "{}"\n'.format(bkgParams["yMax"]) +
    '.ZminSpace "{}"\n'.format(bkgParams["zMin"]) +
    '.ZmaxSpace "{}"\n'.format(bkgParams["zMax"]) +
    '.ApplyInAllDirections "False"\n' +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define background", vba)

defineFloquetModes(self, nModes: int, theta: Union[float, str]=0.0, phi: Union[float, str]=0.0, forcePolar: bool=False, polarAngle: Union[float, str] = 0.0)

# Generate VBA code to define the Floquet modes
vba = (
    'With FloquetPort\n' +
    '.Reset\n' +
    '.SetPolarizationIndependentOfScanAnglePhi "{}", "{}"\n'.format(portParams["polarAngle"], forcePolar) +
    '.SetSortCode "+beta/pw"\n' +
    '.SetCustomizedListFlag "False"\n' +
    '.Port "Zmin"\n' +
    '.SetNumberOfModesConsidered "{:d}"\n'.format(nModes) +
    '.SetDistanceToReferencePlane "0.0"\n' +
    '.SetUseCircularPolarization "False"\n' +
    '.Port "Zmax"\n' +
    '.SetNumberOfModesConsidered "{:d}"\n'.format(nModes) +
    '.SetDistanceToReferencePlane "0.0"\n' +
    '.SetUseCircularPolarization "False"\n' +
    'End With\n' +
    'With Boundary\n' +
    '.SetPeriodicBoundaryAngles "{}", "{}"\n'.format(portParams["theta"], portParams["phi"]) +
    '.SetPeriodicBoundaryAnglesDirection "outward"\n' +
    'End With'
    )

# Send the VBA code to CST
self.__MWS._FlagAsMethod("AddToHistory")
result = self.__MWS.AddToHistory("define Floquet Port boundaries", vba)

runSimulation(self)

self.__MWS.RunSolver()
Edited by Lucas POLO-LOPEZ

Merge request reports

Loading