[FEM] fix handling of vacuum permittivity
- fix message that permittivity object was not handled - set an expression, otherwise the user gets only "0.000" for the default of 8.8e-12 - use as unit the common "F/m" (this is also more user-friendly than "s^4*A^2 / (m^3*kg)") - fix a ToDo
This commit is contained in:
@@ -435,6 +435,10 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
|
|||||||
factor = 1e6;
|
factor = 1e6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (unit == Unit::VacuumPermittivity) {
|
||||||
|
unitString = QString::fromLatin1("F/m");
|
||||||
|
factor = 1;
|
||||||
|
}
|
||||||
else if (unit == Unit::Frequency) {
|
else if (unit == Unit::Frequency) {
|
||||||
if (UnitValue < 1e3) {
|
if (UnitValue < 1e3) {
|
||||||
unitString = QString::fromLatin1("Hz");
|
unitString = QString::fromLatin1("Hz");
|
||||||
|
|||||||
@@ -383,6 +383,10 @@ QString UnitsSchemaMKS::schemaTranslate(const Quantity &quant, double &factor, Q
|
|||||||
factor = 1e6;
|
factor = 1e6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (unit == Unit::VacuumPermittivity) {
|
||||||
|
unitString = QString::fromLatin1("F/m");
|
||||||
|
factor = 1;
|
||||||
|
}
|
||||||
else if (unit == Unit::Work) {
|
else if (unit == Unit::Work) {
|
||||||
if (UnitValue < 1.602176634e-10) {
|
if (UnitValue < 1.602176634e-10) {
|
||||||
unitString = QString::fromLatin1("eV");
|
unitString = QString::fromLatin1("eV");
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class ConstantVacuumPermittivity(base_fempythonobject.BaseFemPythonObject):
|
|||||||
"App::PropertyVacuumPermittivity",
|
"App::PropertyVacuumPermittivity",
|
||||||
"VacuumPermittivity",
|
"VacuumPermittivity",
|
||||||
"Constants",
|
"Constants",
|
||||||
"Set the permittivity of vacuum"
|
"Overwrites default permittivity of vacuum"
|
||||||
)
|
)
|
||||||
obj.VacuumPermittivity = Units.Quantity(constants.vacuum_permittivity())
|
# we must set an expression so that the small value can actually be entered
|
||||||
|
obj.setExpression("VacuumPermittivity", "8.85419e-12")
|
||||||
|
|||||||
@@ -198,13 +198,6 @@ class Writer(object):
|
|||||||
"BoltzmannConstant": constants.boltzmann_constant(),
|
"BoltzmannConstant": constants.boltzmann_constant(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _setConstant(self, name, quantityStr):
|
|
||||||
# TODO without method directly use self.constsdef[name]
|
|
||||||
if name == "PermittivityOfVacuum":
|
|
||||||
theUnit = "s^4*A^2 / (m^3*kg)"
|
|
||||||
self.constsdef[name] = "{} {}".format(self._convert(quantityStr, theUnit), theUnit)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _writeMesh(self):
|
def _writeMesh(self):
|
||||||
mesh = self._getSingleMember("Fem::FemMeshObject")
|
mesh = self._getSingleMember("Fem::FemMeshObject")
|
||||||
unvPath = os.path.join(self.directory, "mesh.unv")
|
unvPath = os.path.join(self.directory, "mesh.unv")
|
||||||
@@ -300,15 +293,19 @@ class Writer(object):
|
|||||||
"""
|
"""
|
||||||
redefine constants in self.constsdef according constant redefine objects
|
redefine constants in self.constsdef according constant redefine objects
|
||||||
"""
|
"""
|
||||||
permittivity_objs = self._getMember("Fem::ConstantVacuumPermittivity")
|
objs = self._getMember("Fem::ConstantVacuumPermittivity")
|
||||||
if len(permittivity_objs) == 1:
|
if len(objs) == 1:
|
||||||
Console.PrintLog("Constand permittivity overwriting.\n")
|
permittivity = float(objs[0].VacuumPermittivity.getValueAs("F/m"))
|
||||||
self._setConstant("PermittivityOfVacuum", permittivity_objs[0].VacuumPermittivity)
|
# since the base unit of FC is in mm, we must scale it to get plain SI
|
||||||
elif len(permittivity_objs) > 1:
|
permittivity = permittivity * 1e-9
|
||||||
|
Console.PrintLog("Overwriting vacuum permittivity with: {}\n".format(permittivity))
|
||||||
|
self.constsdef["PermittivityOfVacuum"] = "{} {}".format(permittivity, "F/m")
|
||||||
|
self._handled(objs[0])
|
||||||
|
elif len(objs) > 1:
|
||||||
Console.PrintError(
|
Console.PrintError(
|
||||||
"More than one permittivity constant overwriting objects ({} objs). "
|
"More than one permittivity constant overwriting objects ({} objs). "
|
||||||
"The permittivity constant overwriting is ignored.\n"
|
"The permittivity constant overwriting is ignored.\n"
|
||||||
.format(len(permittivity_objs))
|
.format(len(objs))
|
||||||
)
|
)
|
||||||
|
|
||||||
def _handleSimulation(self):
|
def _handleSimulation(self):
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def stefan_boltzmann():
|
|||||||
def vacuum_permittivity():
|
def vacuum_permittivity():
|
||||||
# https://forum.freecadweb.org/viewtopic.php?f=18&p=400959#p400959
|
# https://forum.freecadweb.org/viewtopic.php?f=18&p=400959#p400959
|
||||||
# https://en.wikipedia.org/wiki/Permittivity#Vacuum_permittivity
|
# https://en.wikipedia.org/wiki/Permittivity#Vacuum_permittivity
|
||||||
return "8.85419e-12 s^4*A^2 / (m^3*kg)"
|
return "8.85419e-12 F/m"
|
||||||
|
|
||||||
|
|
||||||
def boltzmann_constant():
|
def boltzmann_constant():
|
||||||
|
|||||||
Reference in New Issue
Block a user