Fem: Fix vector potential unit and use enumeration property for boundary condition

This commit is contained in:
marioalexis
2025-01-12 10:17:56 -03:00
parent 10ad2ec955
commit 15c2f33fb8
4 changed files with 766 additions and 790 deletions

View File

@@ -125,26 +125,17 @@ class ESwriter:
# output the FreeCAD label as comment
if obj.Label:
self.write.boundary(name, "! FreeCAD Name", obj.Label)
if obj.Dirichlet:
if obj.BoundaryCondition == "Dirichlet":
if obj.PotentialEnabled:
if hasattr(obj, "Potential"):
# Potential was once a float and scaled not fitting SI units
if isinstance(obj.Potential, float):
savePotential = obj.Potential
obj.removeProperty("Potential")
obj.addProperty(
"App::PropertyElectricPotential",
"Potential",
"Parameter",
"Electric Potential",
)
# scale to match SI units
obj.Potential = savePotential * 1e6
potential = float(obj.Potential.getValueAs("V"))
self.write.boundary(name, "Potential", potential)
elif not obj.Dirichlet and hasattr(obj, "SurfaceChargeDensity"):
sc_density = float(obj.SurfaceChargeDensity.getValueAs("A*s/m^2"))
self.write.boundary(name, "Surface Charge Density", sc_density)
self.write.boundary(
name, "Potential", obj.Potential.getValueAs("V").Value
)
elif obj.BoundaryCondition == "Neumann":
self.write.boundary(
name,
"Surface Charge Density",
obj.SurfaceChargeDensity.getValueAs("C/m^2").Value,
)
if obj.PotentialConstant:
self.write.boundary(name, "Potential Constant", True)
if obj.ElectricInfinity:
@@ -152,8 +143,7 @@ class ESwriter:
if obj.ElectricForcecalculation:
self.write.boundary(name, "Calculate Electric Force", True)
if obj.CapacitanceBodyEnabled:
if hasattr(obj, "CapacitanceBody"):
self.write.boundary(name, "Capacitance Body", obj.CapacitanceBody)
self.write.boundary(name, "Capacitance Body", obj.CapacitanceBody)
self.write.handled(obj)