Skip to content

(optionally) add T/e correction term to Strang Jacobians#1595

Open
zingale wants to merge 29 commits into
AMReX-Astro:developmentfrom
zingale:jacobian_correction
Open

(optionally) add T/e correction term to Strang Jacobians#1595
zingale wants to merge 29 commits into
AMReX-Astro:developmentfrom
zingale:jacobian_correction

Conversation

@zingale
Copy link
Copy Markdown
Member

@zingale zingale commented Jun 26, 2024

this is the dT/dX |_e term that appears in all species
it is now controlled by integrator.correct_jacobian_for_const_e

@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jun 26, 2024

closes #729

@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jun 27, 2024

some Strang data using burn_cell. Build as:

make NETWORK_DIR=subch_simple

then run the old way:

./main3d.gnu.ex inputs_subch_simple integrator.jacobian=1 unit_test.nsteps=1 integrator.correct_jacobian_for_const_e=0

and it take 8084 steps.

Running with the new correction, integrator.correct_jacobian_for_const_e=1 and it takes

6788 steps

@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jun 27, 2024

curiously, with aprox21, it goes the other way, and we are slower

@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jun 27, 2024

for He-C-Fe-group, using the correction terms speeds things up by 4x

./main3d.gnu.ex inputs_subch_simple integrator.jacobian=1 unit_test.nsteps=1 integrator.correct_jacobian_for_const_e=1 unit_test.tmax=1.e-2

104499 without the corrections
24735 with the corrections

@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jun 27, 2024

Here's some test_react runs:

  • aprox13

    with new terms:

    Run time = 2.016436636
    min number of rhs calls: 6
    avg number of rhs calls: 96
    max number of rhs calls: 1171
    min number of steps: 3
    avg number of steps: 75
    max number of steps: 878
    

    without new terms:

    Run time = 2.397303023
    min number of rhs calls: 6
    avg number of rhs calls: 116
    max number of rhs calls: 3932
    min number of steps: 3
    avg number of steps: 94
    max number of steps: 3767
    
  • subch_simple (using inputs_aprox13):

    with new terms:

    Run time = 101.0353978
    min number of rhs calls: 6
    avg number of rhs calls: 3962
    max number of rhs calls: 147079
    min number of steps: 3
    avg number of steps: 2219
    max number of steps: 79369
    

    without new terms:

    Run time = 100.0271792
    min number of rhs calls: 6
    avg number of rhs calls: 3975
    max number of rhs calls: 157375
    min number of steps: 3
    avg number of steps: 2284
    max number of steps: 86380
    

@zingale zingale changed the title [WIP] add a runtime parameter to disable the T/e correction term in Jacobians add a runtime parameter to disable the T/e correction term in Jacobians Jun 28, 2024
@zingale zingale changed the title add a runtime parameter to disable the T/e correction term in Jacobians (optionally) add T/e correction term to Strang Jacobians Jun 28, 2024
@zingale
Copy link
Copy Markdown
Member Author

zingale commented Jul 12, 2024

here's a Castro run with these changes:
http://groot.astro.sunysb.edu/Castro/test-suite/gfortran/2024-07-12-002/index.html

@zingale
Copy link
Copy Markdown
Member Author

zingale commented May 26, 2026

@BenWibking can you make sure that this works for you?

@BenWibking
Copy link
Copy Markdown
Collaborator

@BenWibking can you make sure that this works for you?

It works.

@zingale
Copy link
Copy Markdown
Member Author

zingale commented May 26, 2026

can you review it?

@BenWibking
Copy link
Copy Markdown
Collaborator

reviewing now

Copy link
Copy Markdown
Collaborator

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only mathematically valid for networks that use mass densities.

// now correct the species derivatives
// this constructs dy/dX_k |_e = dy/dX_k |_T - e_{X_k} |_T dy/dT / c_v

if (integrator_rp::correct_jacobian_for_const_e) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to be disabled for number densities, since it assumes the species variables are mass fractions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then I'm confused -- that means that this PR will do nothing for the number density case. Is that your intent?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it needs to be rederived for number densities. I can probably do that later this week if it can wait, or it can go in a separate PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do that in a separate PR. I'll wrap this in an if-test for now

@BenWibking
Copy link
Copy Markdown
Collaborator

It doesn't crash our network, and it still seems to get the right answer, so the correction must be small or zero in our network.

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.

2 participants