diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py index 03aacd2836..96ced53864 100644 --- a/src/Mod/Fem/femcommands/commands.py +++ b/src/Mod/Fem/femcommands/commands.py @@ -34,7 +34,6 @@ import FreeCADGui from FreeCAD import Qt from .manager import CommandManager -from femsolver import settings from femtools.femutils import expandParentObject from femtools.femutils import is_of_type from femsolver.settings import get_default_solver @@ -72,7 +71,8 @@ class _Analysis(CommandManager): FreeCAD.ActiveDocument.commitTransaction() if get_default_solver() != "None": FreeCAD.ActiveDocument.openTransaction("Create default solver") - FreeCADGui.doCommand("ObjectsFem.makeSolver{}(FreeCAD.ActiveDocument)" + FreeCADGui.doCommand( + "ObjectsFem.makeSolver{}(FreeCAD.ActiveDocument)" .format(get_default_solver()) ) FreeCADGui.doCommand( diff --git a/src/Mod/Fem/femexamples/equation_deformation_spring_elmer.py b/src/Mod/Fem/femexamples/equation_deformation_spring_elmer.py index 582b2ef5d6..070f11555a 100644 --- a/src/Mod/Fem/femexamples/equation_deformation_spring_elmer.py +++ b/src/Mod/Fem/femexamples/equation_deformation_spring_elmer.py @@ -23,11 +23,8 @@ import sys import FreeCAD -from FreeCAD import Placement -from FreeCAD import Rotation from FreeCAD import Vector -import Draft import ObjectsFem import Part import Sketcher diff --git a/src/Mod/Fem/femexamples/equation_flow_elmer_2D.py b/src/Mod/Fem/femexamples/equation_flow_elmer_2D.py index cedbd45165..2585c1ab0b 100644 --- a/src/Mod/Fem/femexamples/equation_flow_elmer_2D.py +++ b/src/Mod/Fem/femexamples/equation_flow_elmer_2D.py @@ -182,7 +182,9 @@ def setup(doc=None, solvertype="elmer"): # constraint inlet velocity FlowVelocity_Inlet = ObjectsFem.makeConstraintFlowVelocity(doc, "FlowVelocity_Inlet") FlowVelocity_Inlet.References = [(BooleanFragments, "Edge5")] - FlowVelocity_Inlet.VelocityXFormula = "Variable Coordinate 2; Real MATC \"10*(tx+50e-3)*(50e-3-tx)\"" + FlowVelocity_Inlet.VelocityXFormula = ( + "Variable Coordinate 2; Real MATC \"10*(tx+50e-3)*(50e-3-tx)\"" + ) FlowVelocity_Inlet.VelocityXUnspecified = False FlowVelocity_Inlet.VelocityXHasFormula = True FlowVelocity_Inlet.VelocityYUnspecified = False diff --git a/src/Mod/Fem/femexamples/equation_flow_turbulent_elmer_2D.py b/src/Mod/Fem/femexamples/equation_flow_turbulent_elmer_2D.py index 1fddc7118c..0010d42db1 100644 --- a/src/Mod/Fem/femexamples/equation_flow_turbulent_elmer_2D.py +++ b/src/Mod/Fem/femexamples/equation_flow_turbulent_elmer_2D.py @@ -188,7 +188,9 @@ def setup(doc=None, solvertype="elmer"): # constraint inlet velocity FlowVelocity_Inlet = ObjectsFem.makeConstraintFlowVelocity(doc, "FlowVelocity_Inlet") FlowVelocity_Inlet.References = [(BooleanFragments, "Edge5")] - FlowVelocity_Inlet.VelocityXFormula = "Variable Coordinate 2; Real MATC \"10*(tx+50e-3)*(50e-3-tx)\"" + FlowVelocity_Inlet.VelocityXFormula = ( + "Variable Coordinate 2; Real MATC \"10*(tx+50e-3)*(50e-3-tx)\"" + ) FlowVelocity_Inlet.VelocityXUnspecified = False FlowVelocity_Inlet.VelocityXHasFormula = True FlowVelocity_Inlet.VelocityYUnspecified = False diff --git a/src/Mod/Fem/femexamples/equation_flux_elmer.py b/src/Mod/Fem/femexamples/equation_flux_elmer.py index 166e5610bd..aa25d7e9e1 100644 --- a/src/Mod/Fem/femexamples/equation_flux_elmer.py +++ b/src/Mod/Fem/femexamples/equation_flux_elmer.py @@ -85,8 +85,8 @@ def setup(doc=None, solvertype="elmer"): # solver if solvertype == "elmer": solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer") - equation_electrostatic = ObjectsFem.makeEquationElectrostatic(doc, solver_obj) - equation_heat = ObjectsFem.makeEquationHeat(doc, solver_obj) + ObjectsFem.makeEquationElectrostatic(doc, solver_obj) + ObjectsFem.makeEquationHeat(doc, solver_obj) equation_flux_potential = ObjectsFem.makeEquationFlux(doc, solver_obj) equation_flux_temperature = ObjectsFem.makeEquationFlux(doc, solver_obj) else: diff --git a/src/Mod/Fem/femexamples/equation_magnetodynamics_2D_elmer.py b/src/Mod/Fem/femexamples/equation_magnetodynamics_2D_elmer.py index 4581e18071..3e15c8d396 100644 --- a/src/Mod/Fem/femexamples/equation_magnetodynamics_2D_elmer.py +++ b/src/Mod/Fem/femexamples/equation_magnetodynamics_2D_elmer.py @@ -23,8 +23,6 @@ import sys import FreeCAD -from FreeCAD import Placement -from FreeCAD import Rotation from FreeCAD import Vector import Draft diff --git a/src/Mod/Fem/femexamples/equation_magnetodynamics_elmer.py b/src/Mod/Fem/femexamples/equation_magnetodynamics_elmer.py index 546c557385..142fff0b19 100644 --- a/src/Mod/Fem/femexamples/equation_magnetodynamics_elmer.py +++ b/src/Mod/Fem/femexamples/equation_magnetodynamics_elmer.py @@ -23,8 +23,6 @@ import sys import FreeCAD -from FreeCAD import Rotation -from FreeCAD import Vector import Fem import ObjectsFem diff --git a/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py b/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py index 36b024dbdd..0495be5211 100644 --- a/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py +++ b/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py @@ -25,7 +25,7 @@ __title__ = "FreeCAD FEM calculix constraint initialtemperature" __author__ = "Bernd Hahnebach" __url__ = "https://www.freecadweb.org" -import FreeCAD +from FreeCAD import Units def get_analysis_types(): @@ -48,12 +48,10 @@ def write_constraint(f, femobj, inittemp_obj, ccxwriter): # floats read from ccx should use {:.13G}, see comment in writer module - f.write( - "{},{}\n".format( - ccxwriter.ccx_nall, - FreeCAD.Units.Quantity(inittemp_obj.initialTemperature.getValueAs("K")) - ) - ) + f.write("{},{}\n".format( + ccxwriter.ccx_nall, + Units.Quantity(inittemp_obj.initialTemperature.getValueAs("K")) + )) # Should only be one object in the analysis diff --git a/src/Mod/Fem/femsolver/calculix/write_femelement_matgeosets.py b/src/Mod/Fem/femsolver/calculix/write_femelement_matgeosets.py index 4953a313a1..7475d310dd 100644 --- a/src/Mod/Fem/femsolver/calculix/write_femelement_matgeosets.py +++ b/src/Mod/Fem/femsolver/calculix/write_femelement_matgeosets.py @@ -26,8 +26,6 @@ __author__ = "Bernd Hahnebach" __url__ = "https://www.freecadweb.org" - - def write_femelement_matgeosets(f, ccxwriter): # write mat_geo_sets to file diff --git a/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py b/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py index cc9840a117..6478971840 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py @@ -95,7 +95,10 @@ class Heatwriter: i = -1 for obj in self.write.getMember("Fem::ConstraintTemperature"): i = i + 1 - femobjects = membertools.get_several_member(self.write.analysis, "Fem::ConstraintTemperature") + femobjects = membertools.get_several_member( + self.write.analysis, + "Fem::ConstraintTemperature" + ) femobjects[i]["Nodes"] = meshtools.get_femnodes_by_femobj_with_references( self.write.getSingleMember("Fem::FemMeshObject").FemMesh, femobjects[i] diff --git a/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic2D_writer.py b/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic2D_writer.py index 1be7da3818..77acad45ca 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic2D_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic2D_writer.py @@ -107,7 +107,7 @@ class MgDyn2Dwriter: def handleMagnetodynamic2DMaterial(self, bodies): # check that all bodies have a set material for name in bodies: - if self.write.getBodyMaterial(name) == None: + if self.write.getBodyMaterial(name) is None: raise general_writer.WriteError( "The body {} is not referenced in any material.\n\n".format(name) ) diff --git a/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic_writer.py b/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic_writer.py index 1419b201e6..7e51f2a5da 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/magnetodynamic_writer.py @@ -132,7 +132,7 @@ class MgDynwriter: def handleMagnetodynamicMaterial(self, bodies): # check that all bodies have a set material for name in bodies: - if self.write.getBodyMaterial(name) == None: + if self.write.getBodyMaterial(name) is None: raise general_writer.WriteError( "The body {} is not referenced in any material.\n\n".format(name) ) @@ -219,7 +219,7 @@ class MgDynwriter: # check for PotentialEnabled not Potential since PotentialEnabled was # added later and only with this the imaginary property is available if obj.PotentialEnabled: - # output only if potential is enabled and needed + # output only if potential is enabled and needed potential = float(obj.Potential.getValueAs("V")) self.write.bodyForce(name, "Electric Potential", round(potential, 6)) # imaginary is only needed for harmonic equation diff --git a/src/Mod/Fem/femsolver/elmer/tasks.py b/src/Mod/Fem/femsolver/elmer/tasks.py index 01eaa13b89..9687ac87aa 100644 --- a/src/Mod/Fem/femsolver/elmer/tasks.py +++ b/src/Mod/Fem/femsolver/elmer/tasks.py @@ -354,8 +354,10 @@ class Results(run.Results): def _finishTimeResults(self, time, counter): # we purposely use the decimal dot in the label - self.solver.ElmerTimeResults[counter].Label\ - = self.solver.Name + "_" + str(time) + "_" + "Result" + self.solver.ElmerTimeResults[counter].Label = ( + "{}_{}_Result" + .format(self.solver.Name, time) + ) self.solver.ElmerTimeResults[counter].ViewObject.OnTopWhenSelected = True self.analysis.addObject(self.solver.ElmerTimeResults[counter]) # to assure the user sees something, set the default to Surface diff --git a/src/Mod/Fem/femsolver/elmer/writer.py b/src/Mod/Fem/femsolver/elmer/writer.py index 6655c05d11..970367c58d 100644 --- a/src/Mod/Fem/femsolver/elmer/writer.py +++ b/src/Mod/Fem/femsolver/elmer/writer.py @@ -322,10 +322,13 @@ class Writer(object): self._updateSimulation(self.solver) # output the equation parameters # first check what equations we have - hasHeat = False - for equation in self.solver.Group: - if femutils.is_of_type(equation, "Fem::EquationElmerHeat"): - hasHeat = True + + # hasHeat ist not used, thus commented ATM + # hasHeat = False + # for equation in self.solver.Group: + # if femutils.is_of_type(equation, "Fem::EquationElmerHeat"): + # hasHeat = True + self._simulation("Coordinate System", self.solver.CoordinateSystem) self._simulation("Coordinate Mapping", (1, 2, 3)) # Elmer uses SI base units, but our mesh is in mm, therefore we must tell @@ -615,7 +618,7 @@ class Writer(object): else: activeIn = self.getAllBodies() # Magnetodynamic2D cannot handle all coordinate sysytems - if self.solver.CoordinateSystem in _COORDS_NON_MAGNETO_2D : + if self.solver.CoordinateSystem in _COORDS_NON_MAGNETO_2D: raise WriteError( "The coordinate setting '{}'\n is not " "supported by the equation 'Magnetodynamic2D'.\n\n" @@ -737,7 +740,7 @@ class Writer(object): for obj in self.getMember("App::MaterialObject"): m = obj.Material # fluid material always has KinematicViscosity defined - if not "KinematicViscosity" in m: + if "KinematicViscosity" not in m: return True return False diff --git a/src/Mod/Fem/femtaskpanels/task_constraint_electrostaticpotential.py b/src/Mod/Fem/femtaskpanels/task_constraint_electrostaticpotential.py index a1e3c6e071..04ccea5313 100644 --- a/src/Mod/Fem/femtaskpanels/task_constraint_electrostaticpotential.py +++ b/src/Mod/Fem/femtaskpanels/task_constraint_electrostaticpotential.py @@ -73,13 +73,15 @@ class _TaskPanel(object): self._meshVisible = None # start with vector inputs hidden if no vector is set - if self._obj.AV_re_1_Disabled and \ - self._obj.AV_re_2_Disabled and \ - self._obj.AV_re_3_Disabled and \ - self._obj.AV_im_Disabled and \ - self._obj.AV_im_1_Disabled and \ - self._obj.AV_im_2_Disabled and \ - self._obj.AV_im_3_Disabled: + if ( + self._obj.AV_re_1_Disabled + and self._obj.AV_re_2_Disabled + and self._obj.AV_re_3_Disabled + and self._obj.AV_im_Disabled + and self._obj.AV_im_1_Disabled + and self._obj.AV_im_2_Disabled + and self._obj.AV_im_3_Disabled + ): self._vectorField_visibility(False) self._paramWidget.vectorFieldBox.setChecked(False) QtCore.QObject.connect( diff --git a/src/Mod/Fem/femtaskpanels/task_constraint_initialflowvelocity.py b/src/Mod/Fem/femtaskpanels/task_constraint_initialflowvelocity.py index dcae4622f8..012a8e27b4 100644 --- a/src/Mod/Fem/femtaskpanels/task_constraint_initialflowvelocity.py +++ b/src/Mod/Fem/femtaskpanels/task_constraint_initialflowvelocity.py @@ -34,7 +34,6 @@ from PySide import QtCore import FreeCAD import FreeCADGui -from FreeCAD import Units from femguiutils import selection_widgets from femtools import femutils