Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running DESC until tolerance reached #1387

Closed
Mandelbr0t opened this issue Nov 18, 2024 · 4 comments
Closed

Running DESC until tolerance reached #1387

Mandelbr0t opened this issue Nov 18, 2024 · 4 comments

Comments

@Mandelbr0t
Copy link
Collaborator

Mandelbr0t commented Nov 18, 2024

Hi All,

If one wants to run a given desc converted Vmec input file to convergence for the given M, N, is it enough to do the following:

ftol, gtol, xtol = 1e-16, 1e-16, 1e-16

eq_fam = EquilibriaFamily.solve_continuation_automatic(
        eq=eq, objective="force", optimizer=optimizer, verbose=2, ftol=ftol, gtol=gtol, xtol=xtol
    )

This iteration then stops with

`xtol` condition satisfied.
         Current function value: 2.498e-05
         Total delta_x: 7.862e-02
         ...

I noticed that

InputReader.vmec_to_desc_input(
            path_to_some_vmec_input,
            path_to_desc_input,
        )

inp  = InputReader().parse_inputs(path_to_desc_input)

does not add any solver tolerances to the inp container, is this intended?

Thanks!

@f0uriest
Copy link
Member

what do you mean "to convergence" here? With tolerances that low its likely you'll run into floating point issues before actually reaching them (and you'd also need to set maxiter=inf or something)

When converting a vmec input to desc we don't write any tolerances and use the defaults, since the tolerances in vmec mean different things than the ones in desc so its not clear how to translate them.

@Mandelbr0t
Copy link
Collaborator Author

Mandelbr0t commented Nov 18, 2024

By "to convergence" I mean finding the lowest possible force error for a given M and N.

Edit: I noticed that the iterations of most continuation steps stop due to near-zero or zero step norm.

@f0uriest
Copy link
Member

finding the lowest possible force would generally be done by setting ftol=0, xtol=0, gtol=eps. then you're finding the actual proper mininum, or at least some ball around it where the gradient is finite but tiny (in finite precision you'll basically never get the gradient to actual zero).

The problem is often that the landscape isn't particularly well scaled, so you can get early termination because either f or x stops changing, and you usually won't be able to do better in finite precision. This is a general problem in nonlinear (and linear) optimization and isn't unique to desc.

Another problem is that f, x, and df/dx all have units which makes it tricky because just rescaling the problem can change the convergence criteria, even though it shouldn't. You can check out #1073 for one attempt at a fix for this, which might help in your case as well.

@f0uriest
Copy link
Member

the larger point though is that usually solving to super low tolerances is generally not advised. Formally the problem is only solved in the limit of high resolution, so enforcing optimality at any finite resolution effectively guarantees that you're not solving the actual problem (you usually don't want an exact answer to an approximate problem, it's better to have an answer that is "as approximate" as the problem).

So if you want lower force error, its pretty much always better to increase resolution rather than reducing tolerances beyond a certain point

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

No branches or pull requests

2 participants