验收四路模型并优化拓扑求解性能
This commit is contained in:
1 parent
caca32a513
commit
456c29b3b6
20 files changed
+1085
-137
No files matched your search
@@ -391,6 +391,27 @@ class MechanicalStateReducer:
|
||||
def has_state_events(self) -> bool:
|
||||
return any(group.discrete_endstop_components for group in self.groups)
|
||||
|
||||
def absolute_tolerances(
|
||||
self,
|
||||
default: float,
|
||||
*,
|
||||
mechanical: float = 1.0e-12,
|
||||
) -> list[float]:
|
||||
"""Return state-aligned tolerances with machine-scale mechanics.
|
||||
|
||||
A scalar ``1e-8`` absolute tolerance makes SciPy perturb a zero-valued
|
||||
endstop position across the much smaller unilateral boundary band while
|
||||
constructing finite-difference Jacobians. Mechanical coordinates need
|
||||
a tighter floor; thermodynamic states retain the caller's tolerance.
|
||||
"""
|
||||
values: list[float] = []
|
||||
for entry in self.state_entries:
|
||||
if isinstance(entry, MechanicalConstraintGroup):
|
||||
values.extend([min(default, mechanical)] * 2)
|
||||
else:
|
||||
values.extend([default] * entry.state_size)
|
||||
return values
|
||||
|
||||
def reset_constraint_modes(self) -> None:
|
||||
for group in self.groups:
|
||||
group.reset_mode()
|
||||
@@ -518,7 +539,7 @@ class MechanicalStateReducer:
|
||||
candidates.append((previous_time, group, "lower", lower))
|
||||
elif (
|
||||
lower is not None
|
||||
and previous_position > lower
|
||||
and previous_position > lower + group._boundary_tolerance(lower)
|
||||
and current_position <= lower
|
||||
):
|
||||
candidates.append(
|
||||
@@ -573,7 +594,7 @@ class MechanicalStateReducer:
|
||||
candidates.append((previous_time, group, "upper", upper))
|
||||
elif (
|
||||
upper is not None
|
||||
and previous_position < upper
|
||||
and previous_position < upper - group._boundary_tolerance(upper)
|
||||
and current_position >= upper
|
||||
):
|
||||
candidates.append(
|
||||
|
||||
Reference in new issue
Block a user