Hi @Turro + @project4,
it is inside branch "devel" now. There are some new parameters at head of "solversystem.py".
Code: Select all
SOLVER_STEPS_CONVERGENCY_CHECK = 1000
SOLVER_MIN_CONVERGENCY_RATE = 0.9999
SOLVER_CONVERGENY_ERROR_INIT_VALUE = 1.0e+20
Most work is implemented in Rigid.calculateWorkList(). It looks now as:
Code: Select all
def calculateWorkList(self, doc, workList):
self.printList("WorkList", workList)
for rig in workList:
rig.enableDependencies(workList)
self.lastPositionError = SOLVER_CONVERGENY_ERROR_INIT_VALUE
self.lastAxisError = SOLVER_CONVERGENY_ERROR_INIT_VALUE
self.convergencyCounter = 0
calcCount = 0
goodAccuracy = False
while not goodAccuracy:
maxPosError = 0.0
maxAxisError = 0.0
calcCount += 1
self.stepCount += 1
self.convergencyCounter += 1
# First calculate all the movement vectors
for w in workList:
w.calcMoveData(doc, self)
if w.maxPosError > maxPosError:
maxPosError = w.maxPosError
if w.maxAxisError > maxAxisError:
maxAxisError = w.maxAxisError
# Perform the move
for w in workList:
w.move(doc)
# Enable those 2 lines to see the computation progress on screen
#w.applySolution(doc, self)
#FreeCADGui.updateGui()
# The accuracy is good, apply the solution to FreeCAD's objects
if (maxPosError <= self.mySOLVER_POS_ACCURACY and
maxAxisError <= self.mySOLVER_SPIN_ACCURACY):
# The accuracy is good, we're done here
goodAccuracy = True
# Mark the rigids as tempfixed and add its constrained rigids to pending list to be processed next
FreeCAD.Console.PrintMessage( "{} counts \n".format(calcCount) )
for r in workList:
r.applySolution(doc, self)
r.tempfixed = True
if self.convergencyCounter > SOLVER_STEPS_CONVERGENCY_CHECK:
if (
maxPosError > SOLVER_MIN_CONVERGENCY_RATE * self.lastPositionError or
maxAxisError > SOLVER_MIN_CONVERGENCY_RATE * self.lastAxisError
):
FreeCAD.Console.PrintMessage( "System not solvable, convergency is to bad !\n" )
return False
self.lastPositionError = maxPosError
self.lastAxisError = maxAxisError
self.convergencyCounter = 0
if self.stepCount > SOLVER_MAXSTEPS:
FreeCAD.Console.PrintMessage( "Reached max calculations count ({})\n".format(SOLVER_MAXSTEPS) )
return False
return True