Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Jan 26, 2026

x-lengyel: Avoid unphysical negative c_z in inverse solver.

In underpowered scenarios, the "solution" for inverse mode could be negative seeded impurities, if even with zero impurities the target temperature is below the
requested target temperature.

There was a bug where the solver was allowed to explore these negative values and then propagate them into the state, leading to NaNs.

Two separate fixes where done here:

  1. Clip the seeded impurity ratios to zero in all places where it can be defined in Divertor1D states
  2. Change the residual calculation to compare the calculated c_z to the state vector c_z (which is allowed to explore to negative values). This maintains
    non-zero residuals and a gradient signal. The solver converges to "negative" impurities which are clipped to zero
  3. Fix associated bug where if Z_eff=1 (no impurities) then we got a division by zero in the Jacobian. Just needed to add small value to Zeff within a formula.

@copybara-service copybara-service bot force-pushed the test_860647237 branch 6 times, most recently from 5f6ac11 to 6b18c45 Compare January 29, 2026 23:49
In underpowered scenarios, the "solution" for inverse mode could be negative seeded impurities, if even with zero impurities the target temperature is below the
requested target temperature.

There was a bug where the solver was allowed to explore these negative values and then propagate them into the state, leading to NaNs.

Two separate fixes where done here:
1. Clip the seeded impurity ratios to zero in all places where it can be defined in Divertor1D states
2. Change the residual calculation to compare the calculated c_z to the state vector c_z (which is allowed to explore to negative values). This maintains
non-zero residuals and a gradient signal. The solver converges to "negative" impurities which are clipped to zero
3. Fix associated bug where if Z_eff=1 (no impurities) then we got a division by zero in the Jacobian. Just needed to add small value to Zeff within a formula.

PiperOrigin-RevId: 862939386
@copybara-service copybara-service bot merged commit c45290f into main Jan 30, 2026
@copybara-service copybara-service bot deleted the test_860647237 branch January 30, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant