Derive lift ratios analytically; fix unfair 2-speed comparison#5
Open
featurescript wants to merge 1 commit into
Open
Derive lift ratios analytically; fix unfair 2-speed comparison#5featurescript wants to merge 1 commit into
featurescript wants to merge 1 commit into
Conversation
Replaces the grid searches with derived optima and corrects the 2-speed handicap that made it look worse than a single gear. Ratios (no more search-resolution knobs): - CVT: closed-form per-step optimum G* = (V_oc - I_free*R)*r_eff/(2*Ke*v), clamped to the physical [G_min,G_max]. Verified identical to a 4000-pt brute-force scan (diff 0). Drops cvt_grid. - Single gear: golden-section on the convex time(G); infeasible region uses a G-decreasing penalty so the search climbs to the feasible side. Drops opt_pts. - 2-speed: fair fine pair search whose candidate set always includes the single optimum, so the degenerate pair [G_opt,G_opt] is available. This guarantees single <= 2-speed <= CVT (a 2-speed is a superset of single-gear policies). Drops shift_grid. Why G_min/G_max stay: they are physical hardware limits, not search bounds. The CVT's mathematically-optimal ratio -> infinity as v->0, so it MUST clamp to the largest buildable reduction; without G_max the sim would pretend any load is liftable and the UNREACHABLE finding disappears. Relabeled in the UI as hardware limits. 2-speed result, now honest: - ideal (t_shift=0): shifts once, ~+4% at default mass (strictly beats single) - realistic (t_shift>=0.05): marginal one-shift gain < clutch dead-time, so the optimizer declines to shift and ties single (no more spurious -2.2%) Adds a t_shift sweep variable to chart the 2-speed benefit vs shift dead-time (CVT flat ~+6%, 2-speed +4% at 0 -> 0% by 0.05s). Acceptance test 5 upgraded to assert the full CVT <= 2-speed <= Single ordering at t_shift=0. All 9 self-tests pass; default compare and mass-sweep times unchanged at run dt; closed-form CVT == brute force; drivetrain tab untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4. Addresses two reviewer questions: (1) why the algorithms need a G_min/G_max search range, and (2) whether the 2-speed should beat a single gear in the ideal case.
Ratios are now derived, not grid-searched
G* = (V_oc − I_free·R)·r_eff / (2·Ke·v), clamped to[G_min, G_max]. Verified identical to a 4000-pt brute-force scan (diff 0). Removes thecvt_gridknob.time(G)curve; the infeasible (can't-lift) region returns aG-decreasing penalty so the search climbs to the feasible side. Removesopt_pts.[G_opt, G_opt]is available. Removesshift_grid.Why G_min / G_max stay (the answer to "can they be removed?")
They're physical hardware limits, not search bounds. The CVT's mathematically-optimal ratio → ∞ as v → 0 (infinite reduction = infinite stall force), so it must clamp to the largest buildable reduction. Drop
G_maxand the sim pretends any load is liftable — theUNREACHABLEfeasibility finding evaporates. Relabeled in the UI as hardware limits; only the search-resolution knobs (the real artifacts) were removed.The 2-speed was being judged unfairly
Old code optimized the 2-speed pair on a coarse 8-pt grid while single used 40 pts — so it looked −2.2%, an artifact. An ideal 2-speed is a superset of single-gear policies, so it can't be slower. With the fair search:
Ideal 2-speed strictly beats single (marginally); any realistic shift dead-time exceeds the one-shift gain, so the optimizer declines to shift and ties single — no more spurious negative. New
t_shiftsweep variable charts this directly (CVT flat ~+6%, 2-speed +4%→0 by 0.05s). Acceptance test 5 upgraded to assert the fullCVT ≤ 2-speed ≤ Singleordering at t_shift=0.Validation
🤖 Generated with Claude Code