jac_cell

jac_cell is used to test the accuracy of an analytic Jacobian provided by a network, but comparing to a finite-difference approximation. Given a thermodynamic state, jac_cell evaluates the analytic Jacobian as well as a numerical approximation to it, and then outputs (to stdout) the Jacobian elements side-by-side for each method of computing the Jacobian.

Note

Some integrators, like VODE, have their own numerical Jacobian routines. This test uses the implementation in integration/util/numerical_jacobian.H, which closely follows the ideas of the VODE numerical approximation, as described in [58].

Getting Started

The jac_cell code is located in Microphysics/unit_test/jac_cell. An inputs file which sets the default parameters for your thermodynamic state is needed to run the test.

Setting the thermodynamics

The parameters that affect the thermodynamics are:

  • unit_test.density : the initial density

  • unit_test.temperature : the initial temperature

The composition can be set either by specifying individual mass fractions or setting unit_test.uniform_xn as described in Defining composition.

If the values don’t sum to 1 initially, then the test will do a normalization. This normalization can be disabled by setting:

unit_test.skip_initial_normalization = 1

Building and Running the Code

The code can be built simply as:

make

Note

By default, this will build with the aprox13 network, which uses the C++ templating method (Templated Network Righthand Sides) of building the analytic Jacobian at compile-time. The network can be changed via the build parameter NETWORK_DIR.

Important

The screening routines provided by Microphysics do not return the derivative of the screening factor with respect to composition. This means that the analytic Jacobian provided by the network will ignore this contribution, but the numerical Jacobian will implicitly include it.

To compare just the network Jacobian elements, it is suggested that you build with SCREEN_METHOD=null.

The build process will automatically create links in the build directory to any required EOS table.

To run the code, in the jac_cell directory run:

./main3d.gnu.ex inputs

where inputs is the provided inputs file. You may edit the thermodynamic state in that file prior to running.

Output

All output is directed to stdout. Example output is shown below (this output includes screening, highlighting the difference that the screening composition derivatives make):

Initializing AMReX (26.09-119-ge60cdc18711c)...
AMReX (26.09-119-ge60cdc18711c) initialized
starting the single zone burn...
   element           numerical              analytic             rel. error     
J(He4 , He4 ) =         -386901.0562          -386731.7937      4.3767432342e-04
J(He4 , C12 ) =           1538.83613           1933.784657      2.0423604336e-01
J(He4 , O16 ) =         -11984.43367           -11476.6414      4.4245720707e-02
J(He4 , Ne20) =         -226229.9236          -225609.2784      2.7509735539e-03
J(He4 , Mg24) =         -118533.7928           -117800.314      6.2264588927e-03
J(He4 , Si28) =         -13102.92749          -12256.60576      6.9050253296e-02
J(He4 , S32 ) =         -13739.13964          -12779.96931      7.5052631883e-02
J(He4 , Ar36) =         -8735.824012          -7663.806831      1.3988050646e-01
J(He4 , Ca40) =         -1917.505444           -732.656645      1.6171951858e+00
J(He4 , Ti44) =         -1801.580358          -503.8873676      2.5753632141e+00
J(He4 , Cr48) =         -1902.430547          -491.8918128      2.8675792058e+00
J(He4 , Fe52) =         -1987.160097          -463.7787961      3.2847152864e+00
J(He4 , Ni56) =         -2104.486528          -468.2606765      3.4942627764e+00
J(He4 , e   ) =     -3.302305762e-14      -3.302305672e-14      2.7190018159e-08

J(C12 , He4 ) =         -1544.888563          -1539.304472      3.6276711701e-03
J(C12 , C12 ) =         -14163.60628          -14150.57674      9.2077832258e-04
J(C12 , O16 ) =         -26.31037223          -9.557978749      1.7527129869e+00
J(C12 , Ne20) =         -22.40516055          -1.930001541      1.0608882208e+01
J(C12 , Mg24) =         -31.64594981          -7.448087863      3.2488690243e+00
J(C12 , Si28) =         -39.31004354          -11.38957809      2.4514047154e+00
J(C12 , S32 ) =         -45.98896291          -14.34569577      2.2057673367e+00
J(C12 , Ar36) =         -52.01096713           -16.6448984      2.1247392372e+00
J(C12 , Ca40) =         -57.57313075          -18.48426051      2.1147110661e+00
J(C12 , Ti44) =         -62.80086484          -19.98919314      2.1417408596e+00
J(C12 , Cr48) =         -67.77757842          -21.24330367      2.1905385094e+00
J(C12 , Fe52) =         -72.56164943          -22.30447411      2.2532329190e+00
J(C12 , Ni56) =         -77.19392628          -23.21404878      2.3253107632e+00
J(C12 , e   ) =     -1.637120092e-15      -1.637119821e-15      1.6525271564e-07

J(O16 , He4 ) =         -44251.69974          -44237.68858      3.1672435937e-04
J(O16 , C12 ) =          2167.279422           2199.972504      1.4860677508e-02
J(O16 , O16 ) =          -46494.3376          -46452.30341      9.0488920949e-04
J(O16 , Ne20) =          6268.468387           6319.843302      8.1291438617e-03
J(O16 , Mg24) =         -58.72063931           1.994691196      3.0438461168e+01
J(O16 , Si28) =         -67.00603097           3.050271636      2.2967234061e+01
J(O16 , S32 ) =         -75.55571467           3.841956965      2.0665945076e+01
J(O16 , Ar36) =         -84.28093184           4.457712222      1.9906768236e+01
J(O16 , Ca40) =         -93.12930016           4.950316427      1.9812797431e+01
J(O16 , Ti44) =         -102.0668362           5.353356231      2.0065952612e+01
J(O16 , Cr48) =         -111.0723391           5.689222735      2.0523288904e+01
J(O16 , Fe52) =          -120.129117           5.973417468      2.1110618030e+01
J(O16 , Ni56) =         -129.2264943           6.217012954      2.1785945793e+01
J(O16 , e   ) =      4.384415228e-16       4.384411885e-16      7.6256397779e-07

J(Ne20, He4 ) =         -1071437.231          -1070943.128      4.6137250303e-04
J(Ne20, C12 ) =           10295.4965           11448.44121      1.0070757144e-01
J(Ne20, O16 ) =          56883.61948           58365.98222      2.5397717738e-02
J(Ne20, Ne20) =         -1145561.976           -1143750.19      1.5840750986e-03
J(Ne20, Mg24) =         -2527.616919          -386.4347053      5.5408641742e+00
J(Ne20, Si28) =         -3061.548719          -590.9393321      4.1808173068e+00
J(Ne20, S32 ) =         -3544.317148          -744.3151805      3.7618498741e+00
J(Ne20, Ar36) =         -3993.040141           -863.607507      3.6236746543e+00
J(Ne20, Ca40) =         -4417.866583          -959.0413682      3.6065443359e+00
J(Ne20, Ti44) =         -4825.366803          -1037.123618      3.6526438294e+00
J(Ne20, Cr48) =         -5219.853315           -1102.19216      3.7358831826e+00
J(Ne20, Fe52) =         -5604.291196          -1157.250157      3.8427655525e+00
J(Ne20, Ni56) =         -5980.914429          -1204.442726      3.9657109483e+00
J(Ne20, e   ) =     -8.494068043e-14      -8.494067874e-14      1.9876211905e-08

J(Mg24, He4 ) =          654844.2806           654499.0608      5.2745651618e-04
J(Mg24, C12 ) =          435.4230384          -370.1757474      2.1762603073e+00
J(Mg24, O16 ) =          929.9962063          -105.7431928      9.7948565002e+00
J(Mg24, Ne20) =          1364203.922            1362938.07      9.2876743789e-04
J(Mg24, Mg24) =         -704261.6416          -705757.6926      2.1197800237e-03
J(Mg24, Si28) =          1944.546334           218.3204419      7.9068449889e+00
J(Mg24, S32 ) =          2231.306642           274.9843883      7.1143029818e+00
J(Mg24, Ar36) =          2505.576486           319.0564807      6.8530813119e+00
J(Mg24, Ca40) =          2770.981131           354.3141547      6.8206899010e+00
J(Mg24, Ti44) =          3030.000681           383.1613424      6.9078976539e+00
J(Mg24, Cr48) =          3284.193323           407.2006656      7.0652945854e+00
J(Mg24, Fe52) =          3534.649522           427.5416313      7.2673809134e+00
J(Mg24, Ni56) =          3782.237956           444.9767448      7.4998553286e+00
J(Mg24, e   ) =      3.138100654e-14       3.138100793e-14      4.4423169309e-08

J(Si28, He4 ) =          733740.6263             733459.59      3.8316532322e-04
J(Si28, C12 ) =         -236.8292666          -892.4961339      7.3464392996e-01
J(Si28, O16 ) =           574.578026          -268.5001072      3.1399545497e+00
J(Si28, Ne20) =          1117.750234           87.29710477      1.1803978282e+01
J(Si28, Mg24) =          825105.1884           823887.4217      1.4780741532e-03
J(Si28, Si28) =          -82267.7835          -83672.86265      1.6792531144e-02
J(Si28, S32 ) =          2244.127686           651.6029126      2.4440111331e+00
J(Si28, Ar36) =          2532.726899           752.8757923      2.3640700429e+00
J(Si28, Ca40) =          2803.275313           836.0731283      2.3529068426e+00
J(Si28, Ti44) =          3058.658852           904.1436759      2.3829345194e+00
J(Si28, Cr48) =          3302.735385           960.8691322      2.4372374696e+00
J(Si28, Fe52) =            3538.1484           1008.867595      2.5070493067e+00
J(Si28, Ni56) =          3766.666407           1050.009135      2.5872701306e+00
J(Si28, e   ) =      7.404959203e-14       7.404958884e-14      4.3084138201e-08

J(S32 , He4 ) =         -3580.328682          -3574.618369      1.5974609161e-03
J(S32 , C12 ) =           8.04608259           21.35632784      6.2324596951e-01
J(S32 , O16 ) =         -10.40027404           6.731919014      2.5449196604e+00
J(S32 , Ne20) =         -22.96819788          -2.046323217      1.0224130035e+01
J(S32 , Mg24) =         -32.64411602          -7.896985981      3.1337436959e+00
J(S32 , Si28) =           96174.2781           96202.81719      2.9665544355e-04
J(S32 , S32 ) =         -99978.56511          -99946.20439      3.2378140270e-04
J(S32 , Ar36) =         -42.78877369          -6.622063239      5.4615471257e+00
J(S32 , Ca40) =           -59.590923          -19.59831151      2.0406151554e+00
J(S32 , Ti44) =         -64.96182659          -21.19394681      2.0651122781e+00
J(S32 , Cr48) =         -70.09376854          -22.52364289      2.1120085182e+00
J(S32 , Fe52) =         -75.06398858          -23.64877035      2.1741180401e+00
J(S32 , Ni56) =         -79.83062948          -24.61316531      2.2434117465e+00
J(S32 , e   ) =     -1.735789154e-15      -1.735789442e-15      1.6628439238e-07

J(Ar36, He4 ) =          46086.53162           46071.57903      3.2455142324e-04
J(Ar36, C12 ) =         -24.11889018          -59.01830805      5.9133206330e-01
J(Ar36, O16 ) =          26.26894988          -18.59747588      2.4125008168e+00
J(Ar36, Ne20) =          60.49242539           5.655023413      9.6971131637e+00
J(Ar36, Mg24) =          86.63689247           21.82335628      2.9699160553e+00
J(Ar36, Si28) =          108.1539016           33.37216547      2.2408415841e+00
J(Ar36, S32 ) =          112545.6504           112460.9001      7.5359836435e-04
J(Ar36, Ar36) =         -65833.81509          -65928.53603      1.4367213813e-03
J(Ar36, Ca40) =          160.4642177           55.76969455      1.8772654938e+00
J(Ar36, Ti44) =           173.235213           58.56956733      1.9577683574e+00
J(Ar36, Cr48) =          186.8760509           62.24418844      2.0023052041e+00
J(Ar36, Fe52) =          199.9634644           65.35348322      2.0597216017e+00
J(Ar36, Ni56) =          212.5928074           68.01859303      2.1255102158e+00
J(Ar36, e   ) =      4.796861622e-15       4.796861932e-15      6.4508097611e-08

J(Ca40, He4 ) =          68936.76349           68892.89781      6.3672275779e-04
J(Ca40, C12 ) =         -21.37672362          -123.7247389      8.2722353017e-01
J(Ca40, O16 ) =          92.60590241          -38.98735705      3.3752803326e+00
J(Ca40, Ne20) =           172.688813           11.85507207      1.3566660750e+01
J(Ca40, Mg24) =          235.8250397           45.75002481      4.1546428802e+00
J(Ca40, Si28) =           289.279374           69.96070534      3.1348836111e+00
J(Ca40, S32 ) =          336.6818312           88.11871574      2.8207755114e+00
J(Ca40, Ar36) =          73674.38243           73396.57753      3.7849843880e-03
J(Ca40, Ca40) =         -3181.015849          -3488.062902      8.8027957453e-02
J(Ca40, Ti44) =          605.9215887            269.631437      1.2472215976e+00
J(Ca40, Cr48) =          496.0195798           130.4874067      2.8012831461e+00
J(Ca40, Fe52) =          531.7806992           137.0056668      2.8814503920e+00
J(Ca40, Ni56) =          566.6106385           142.5927469      2.9736287481e+00
J(Ca40, e   ) =      1.005604098e-14        1.00560404e-14      5.7982829663e-08

J(Ti44, He4 ) =          2668.743332           2666.610962      7.9965532037e-04
J(Ti44, C12 ) =          1.238968178          -3.736552242      1.3315805850e+00
J(Ti44, O16 ) =          5.219659626          -1.177438705      5.4330627169e+00
J(Ti44, Ne20) =          8.176705476          0.3580294168      2.1838082825e+01
J(Ti44, Mg24) =          10.62185414           1.381674832      6.6876656485e+00
J(Ti44, Si28) =          12.77460702           2.112850128      5.0461491577e+00
J(Ti44, S32 ) =          14.74456604             2.6612316      4.5405046462e+00
J(Ti44, Ar36) =           16.5926625           3.087750523      4.3737056716e+00
J(Ti44, Ca40) =          3978.151195           3963.224704      3.7662491481e-03
J(Ti44, Ti44) =         -1410.451232          -1426.799345      1.1457892127e-02
J(Ti44, Cr48) =          21.71303639           3.943382305      4.5061961300e+00
J(Ti44, Fe52) =          23.32886523           4.137643256      4.6382012149e+00
J(Ti44, Ni56) =          24.91917548           4.306376017      4.7865767830e+00
J(Ti44, e   ) =      3.036977677e-16       3.036977135e-16      1.7855243866e-07

J(Cr48, He4 ) =          614.7614844           614.2065869      9.0343788248e-04
J(Cr48, C12 ) =        -0.1747033379           -1.46944523      8.8110932320e-01
J(Cr48, O16 ) =          1.201593305         -0.4630422852      3.5949969230e+00
J(Cr48, Ne20) =            2.1753907          0.1407994816      1.4450274925e+01
J(Cr48, Mg24) =          2.947870284          0.5433606595      4.4252552742e+00
J(Cr48, Si28) =          3.605375763          0.8309043579      3.3390983913e+00
J(Cr48, S32 ) =          4.190958113           1.046562132      3.0045000543e+00
J(Cr48, Ar36) =          4.728616507           1.214295956      2.8941219269e+00
J(Cr48, Ca40) =          5.232734331           1.348483015      2.8804599479e+00
J(Cr48, Ti44) =          1390.049151            1385.79498      3.0698418663e-03
J(Cr48, Cr48) =         -754.4384225          -759.0625177      6.0918502718e-03
J(Cr48, Fe52) =          6.621805499           1.627780664      3.0679961659e+00
J(Cr48, Ni56) =          7.057441608           1.693535453      3.1672830614e+00
J(Cr48, e   ) =       1.19432887e-16       1.194328695e-16      1.4665919649e-07

J(Fe52, He4 ) =          632.9421872           632.2558149      1.0855926645e-03
J(Fe52, C12 ) =        -0.1711193576          -1.772643921      9.0346659272e-01
J(Fe52, O16 ) =          1.500523358         -0.5585843387      3.6862968646e+00
J(Fe52, Ne20) =          2.686529769          0.1698514107      1.4816941166e+01
J(Fe52, Mg24) =          3.629742825          0.6554752436      4.5375742414e+00
J(Fe52, Si28) =          4.434187596            1.00234941      3.4237942897e+00
J(Fe52, S32 ) =           5.15193241           1.262505035      3.0807222685e+00
J(Fe52, Ar36) =          5.811846257           1.464848298      2.9675413915e+00
J(Fe52, Ca40) =          6.431285246           1.626722909      2.9535222675e+00
J(Fe52, Ti44) =           7.02131108           1.759165773      2.9912731293e+00
J(Fe52, Cr48) =          831.5828167           825.8631074      6.9257354002e-03
J(Fe52, Fe52) =         -172.1130683          -178.2903646      3.4647392952e-02
J(Fe52, Ni56) =           8.67797769           2.043087474      3.2474822050e+00
J(Fe52, e   ) =        1.4407613e-16       1.440761083e-16      1.5026794681e-07

J(Ni56, He4 ) =          190.5614891           190.3319107      1.2062002911e-03
J(Ni56, C12 ) =       -0.04871014481         -0.5843896922      9.1664783712e-01
J(Ni56, O16 ) =         0.5045792589          -0.184149183      3.7400570055e+00
J(Ni56, Ne20) =         0.8977755497         0.05599512255      1.5033102686e+01
J(Ni56, Mg24) =          1.210925284          0.2160913262      4.6037662650e+00
J(Ni56, Si28) =          1.478328594          0.3304457574      3.4737405797e+00
J(Ni56, S32 ) =          1.717144845          0.4162115808      3.1256536919e+00
J(Ni56, Ar36) =          1.936906672          0.4829183324      3.0108369101e+00
J(Ni56, Ca40) =          2.143324048          0.5362837336      2.9966232691e+00
J(Ni56, Ti44) =          2.340035525          0.5799463346      3.0349173453e+00
J(Ni56, Cr48) =           2.52947455          0.6163318354      3.1040790112e+00
J(Ni56, Fe52) =          196.8315355           194.7653441      1.0608619695e-02
J(Ni56, Ni56) =          2.892625537          0.6733845963      3.2956514786e+00
J(Ni56, e   ) =      4.749774962e-17       4.749774706e-17      5.3764938814e-08

J(e   , He4 ) =      8.557355646e+23        8.55354597e+23      4.4539137436e-04
J(e   , C12 ) =      3.253492329e+21       2.377349469e+21      3.6853768077e-01
J(e   , O16 ) =      1.407824852e+22       1.297205545e+22      8.5275080341e-02
J(e   , Ne20) =      5.099953876e+23       5.086139174e+23      2.7161471796e-03
J(e   , Mg24) =      2.852905494e+23       2.836717124e+23      5.7067269979e-03
J(e   , Si28) =      2.258348807e+22       2.067637623e+22      9.2236270957e-02
J(e   , S32 ) =      2.278872757e+22       2.066347103e+22      1.0285089717e-01
J(e   , Ar36) =       1.55712523e+22       1.320266941e+22      1.7940181773e-01
J(e   , Ca40) =      3.918079028e+21       1.285810971e+21      2.0471656533e+00
J(e   , Ti44) =      3.973002198e+21       1.105634564e+21      2.5934135263e+00
J(e   , Cr48) =       4.23547637e+21       1.088148496e+21      2.8923698234e+00
J(e   , Fe52) =      4.413681758e+21       1.041751218e+21      3.2367905924e+00
J(e   , Ni56) =      4.682037199e+21        1.05638977e+21      3.4321114543e+00
J(e   , e   ) =          74499.43446           74499.57032      1.8236417247e-06

AMReX (26.09-119-ge60cdc18711c) finalized