@@ -290,13 +290,13 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
290
290
calc_J! (J, integrator, cache) # Store the calculated jac as it won't change in internal discretisation
291
291
for index in 1 : (n_curr + 1 )
292
292
dt_temp = dt / sequence[index]
293
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_temp, J, false )
293
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_temp, J, true )
294
294
integrator. stats. nw += 1
295
295
@. . broadcast= false k_tmps[1 ]= integrator. fsalfirst
296
296
@. . broadcast= false u_tmps[1 ]= uprev
297
297
298
298
for j in 1 : sequence[index]
299
- @. . broadcast= false linsolve_tmps[1 ]= dt_temp * k_tmps[1 ]
299
+ @. . broadcast= false linsolve_tmps[1 ]= k_tmps[1 ]
300
300
301
301
linsolve = cache. linsolve[1 ]
302
302
@@ -311,9 +311,8 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
311
311
cache. linsolve[1 ] = linres. cache
312
312
313
313
integrator. stats. nsolve += 1
314
- @. . broadcast= false k_tmps[1 ]= - k_tmps[1 ]
315
314
@. . broadcast= false u_tmps2[1 ]= u_tmps[1 ]
316
- @. . broadcast= false u_tmps[1 ]= u_tmps[1 ] + k_tmps[1 ]
315
+ @. . broadcast= false u_tmps[1 ]= u_tmps[1 ] - k_tmps[1 ]
317
316
if index <= 2 && j >= 2
318
317
# Deuflhard Stability check for initial two sequences
319
318
@. . broadcast= false diff2[1 ]= u_tmps[1 ] - u_tmps2[1 ]
@@ -347,12 +346,11 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
347
346
dt_temp = dt / sequence[index]
348
347
jacobian2W! (
349
348
W[Threads. threadid ()], integrator. f. mass_matrix, dt_temp, J,
350
- false )
349
+ true )
351
350
@. . broadcast= false k_tmps[Threads. threadid ()]= integrator. fsalfirst
352
351
@. . broadcast= false u_tmps[Threads. threadid ()]= uprev
353
352
for j in 1 : sequence[index]
354
- @. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_temp *
355
- k_tmps[Threads. threadid ()]
353
+ @. . broadcast= false linsolve_tmps[Threads. threadid ()]= k_tmps[Threads. threadid ()]
356
354
357
355
linsolve = cache. linsolve[Threads. threadid ()]
358
356
@@ -369,9 +367,8 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
369
367
370
368
cache. linsolve[Threads. threadid ()] = linres. cache
371
369
372
- @. . broadcast= false k_tmps[Threads. threadid ()]= - k_tmps[Threads. threadid ()]
373
370
@. . broadcast= false u_tmps2[Threads. threadid ()]= u_tmps[Threads. threadid ()]
374
- @. . broadcast= false u_tmps[Threads. threadid ()]= u_tmps[Threads. threadid ()] +
371
+ @. . broadcast= false u_tmps[Threads. threadid ()]= u_tmps[Threads. threadid ()] -
375
372
k_tmps[Threads. threadid ()]
376
373
if index <= 2 && j >= 2
377
374
# Deuflhard Stability check for initial two sequences
@@ -454,7 +451,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
454
451
@. . broadcast= false u_tmps[1 ]= uprev
455
452
456
453
for j in 1 : sequence[n_curr + 1 ]
457
- @. . broadcast= false linsolve_tmps[1 ]= dt_temp * k_tmps[1 ]
454
+ @. . broadcast= false linsolve_tmps[1 ]= k_tmps[1 ]
458
455
459
456
linsolve = cache. linsolve[1 ]
460
457
@@ -471,8 +468,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache,
471
468
cache. linsolve[1 ] = linres. cache
472
469
473
470
integrator. stats. nsolve += 1
474
- @. . broadcast= false k_tmps[1 ]= - k_tmps[1 ]
475
- @. . broadcast= false u_tmps[1 ]= u_tmps[1 ] + k_tmps[1 ]
471
+ @. . broadcast= false u_tmps[1 ]= u_tmps[1 ] - k_tmps[1 ]
476
472
f (k_tmps[1 ], u_tmps[1 ], p, t + j * dt_temp)
477
473
OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
478
474
end
@@ -1174,7 +1170,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1174
1170
for i in 0 : n_curr
1175
1171
j_int = 4 * subdividing_sequence[i + 1 ]
1176
1172
dt_int = dt / j_int # Stepsize of the ith internal discretisation
1177
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
1173
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
1178
1174
integrator. stats. nw += 1
1179
1175
@. . broadcast= false u_temp2= uprev
1180
1176
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
@@ -1247,7 +1243,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1247
1243
j_int_temp = 4 * subdividing_sequence[index + 1 ]
1248
1244
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
1249
1245
jacobian2W! (W[Threads. threadid ()], integrator. f. mass_matrix,
1250
- dt_int_temp, J, false )
1246
+ dt_int_temp, J, true )
1251
1247
@. . broadcast= false u_temp4[Threads. threadid ()]= uprev
1252
1248
@. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
1253
1249
fsalfirst
@@ -1334,7 +1330,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1334
1330
j_int_temp = 4 * subdividing_sequence[index + 1 ]
1335
1331
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
1336
1332
jacobian2W! (W[Threads. threadid ()], integrator. f. mass_matrix,
1337
- dt_int_temp, J, false )
1333
+ dt_int_temp, J, true )
1338
1334
@. . broadcast= false u_temp4[Threads. threadid ()]= uprev
1339
1335
@. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
1340
1336
fsalfirst
@@ -1460,7 +1456,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1460
1456
# Update cache.T
1461
1457
j_int = 4 * subdividing_sequence[n_curr + 1 ]
1462
1458
dt_int = dt / j_int # Stepsize of the new internal discretisation
1463
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
1459
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
1464
1460
integrator. stats. nw += 1
1465
1461
@. . broadcast= false u_temp2= uprev
1466
1462
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
@@ -1471,8 +1467,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1471
1467
cache. linsolve[1 ] = linres. cache
1472
1468
1473
1469
integrator. stats. nsolve += 1
1474
- @. . broadcast= false k= - k
1475
- @. . broadcast= false u_temp1= u_temp2 + k # Euler starting step
1470
+ @. . broadcast= false u_temp1= u_temp2 - k # Euler starting step
1476
1471
for j in 2 : j_int
1477
1472
f (k, cache. u_temp1, p, t + (j - 1 ) * dt_int)
1478
1473
OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
@@ -1484,8 +1479,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache,
1484
1479
cache. linsolve[1 ] = linres. cache
1485
1480
1486
1481
integrator. stats. nsolve += 1
1487
- @. . broadcast= false k= - k
1488
- @. . broadcast= false T[n_curr + 1 ]= 2 * u_temp1 - u_temp2 + 2 * k # Explicit Midpoint rule
1482
+ @. . broadcast= false T[n_curr + 1 ]= 2 * u_temp1 - u_temp2 - 2 * k # Explicit Midpoint rule
1489
1483
@. . broadcast= false u_temp2= u_temp1
1490
1484
@. . broadcast= false u_temp1= T[n_curr + 1 ]
1491
1485
end
@@ -2548,7 +2542,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2548
2542
for i in 0 : n_curr
2549
2543
j_int = 4 * subdividing_sequence[i + 1 ]
2550
2544
dt_int = dt / j_int # Stepsize of the ith internal discretisation
2551
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
2545
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
2552
2546
integrator. stats. nw += 1
2553
2547
@. . broadcast= false u_temp2= uprev
2554
2548
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
@@ -2570,7 +2564,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2570
2564
for j in 2 : (j_int + 1 )
2571
2565
f (k, cache. u_temp1, p, t + (j - 1 ) * dt_int)
2572
2566
OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
2573
- @. . broadcast= false linsolve_tmps[1 ]= dt_int * k - (u_temp1 - u_temp2)
2567
+ @. . broadcast= false linsolve_tmps[1 ]= k - (u_temp1 - u_temp2)/ dt_int
2574
2568
2575
2569
linsolve = cache. linsolve[1 ]
2576
2570
@@ -2584,8 +2578,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2584
2578
cache. linsolve[1 ] = linres. cache
2585
2579
2586
2580
integrator. stats. nsolve += 1
2587
- @. . broadcast= false k= - k
2588
- @. . broadcast= false T[i + 1 ]= 2 * u_temp1 - u_temp2 + 2 * k # Explicit Midpoint rule
2581
+ @. . broadcast= false T[i + 1 ]= 2 * u_temp1 - u_temp2 - 2 * k # Explicit Midpoint rule
2589
2582
if (j == j_int + 1 )
2590
2583
@. . broadcast= false T[i + 1 ]= 0.5 (T[i + 1 ] + u_temp2)
2591
2584
end
@@ -2624,7 +2617,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2624
2617
j_int_temp = 4 * subdividing_sequence[index + 1 ]
2625
2618
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
2626
2619
jacobian2W! (W[Threads. threadid ()], integrator. f. mass_matrix,
2627
- dt_int_temp, J, false )
2620
+ dt_int_temp, J, true )
2628
2621
@. . broadcast= false u_temp4[Threads. threadid ()]= uprev
2629
2622
@. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
2630
2623
fsalfirst
@@ -2652,10 +2645,9 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2652
2645
f (k_tmps[Threads. threadid ()],
2653
2646
cache. u_temp3[Threads. threadid ()],
2654
2647
p, t + (j - 1 ) * dt_int_temp)
2655
- @. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
2656
- k_tmps[Threads. threadid ()] -
2648
+ @. . broadcast= false linsolve_tmps[Threads. threadid ()]= k_tmps[Threads. threadid ()] -
2657
2649
(u_temp3[Threads. threadid ()] -
2658
- u_temp4[Threads. threadid ()])
2650
+ u_temp4[Threads. threadid ()]) / dt_int_temp
2659
2651
2660
2652
linsolve = cache. linsolve[Threads. threadid ()]
2661
2653
if ! repeat_step && j == 1
@@ -2670,10 +2662,9 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2670
2662
end
2671
2663
cache. linsolve[Threads. threadid ()] = linres. cache
2672
2664
2673
- @. . broadcast= false k_tmps[Threads. threadid ()]= - k_tmps[Threads. threadid ()]
2674
2665
@. . broadcast= false T[index + 1 ]= 2 *
2675
2666
u_temp3[Threads. threadid ()] -
2676
- u_temp4[Threads. threadid ()] +
2667
+ u_temp4[Threads. threadid ()] -
2677
2668
2 * k_tmps[Threads. threadid ()] # Explicit Midpoint rule
2678
2669
if (j == j_int_temp + 1 )
2679
2670
@. . broadcast= false T[index + 1 ]= 0.5 (T[index + 1 ] +
@@ -2718,7 +2709,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2718
2709
index == - 1 && continue
2719
2710
j_int_temp = 4 * subdividing_sequence[index + 1 ]
2720
2711
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
2721
- jacobian2W! (W[tid], integrator. f. mass_matrix, dt_int_temp, J, false )
2712
+ jacobian2W! (W[tid], integrator. f. mass_matrix, dt_int_temp, J, true )
2722
2713
@. . broadcast= false u_temp4[tid]= uprev
2723
2714
@. . broadcast= false linsolvetmp= dt_int_temp * fsalfirst
2724
2715
@@ -2737,8 +2728,8 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2737
2728
@. . broadcast= false diff1[tid]= u_temp3[tid] - u_temp4[tid]
2738
2729
for j in 2 : (j_int_temp + 1 )
2739
2730
f (ktmp, cache. u_temp3[tid], p, t + (j - 1 ) * dt_int_temp)
2740
- @. . broadcast= false linsolvetmp= dt_int_temp * ktmp -
2741
- (u_temp3[tid] - u_temp4[tid])
2731
+ @. . broadcast= false linsolvetmp= ktmp -
2732
+ (u_temp3[tid] - u_temp4[tid])/ dt_int_temp
2742
2733
2743
2734
linsolve = cache. linsolve[tid]
2744
2735
@@ -2753,9 +2744,8 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2753
2744
end
2754
2745
cache. linsolve[tid] = linres. cache
2755
2746
2756
- @. . broadcast= false ktmp= - ktmp
2757
2747
@. . broadcast= false T[index + 1 ]= 2 * u_temp3[tid] -
2758
- u_temp4[tid] + 2 * ktmp # Explicit Midpoint rule
2748
+ u_temp4[tid] - 2 * ktmp # Explicit Midpoint rule
2759
2749
if (j == j_int_temp + 1 )
2760
2750
@. . broadcast= false T[index + 1 ]= 0.5 (T[index + 1 ] +
2761
2751
u_temp4[tid])
@@ -2833,7 +2823,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache
2833
2823
# Update cache.T
2834
2824
j_int = 4 * subdividing_sequence[n_curr + 1 ]
2835
2825
dt_int = dt / j_int # Stepsize of the new internal discretisation
2836
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
2826
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
2837
2827
integrator. stats. nw += 1
2838
2828
@. . broadcast= false u_temp2= uprev
2839
2829
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
@@ -3247,7 +3237,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3247
3237
for i in 0 : n_curr
3248
3238
j_int = sequence_factor * subdividing_sequence[i + 1 ]
3249
3239
dt_int = dt / j_int # Stepsize of the ith internal discretisation
3250
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
3240
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
3251
3241
integrator. stats. nw += 1
3252
3242
@. . broadcast= false u_temp2= uprev
3253
3243
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
@@ -3270,7 +3260,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3270
3260
for j in 2 : (j_int + 1 )
3271
3261
f (k, cache. u_temp1, p, t + (j - 1 ) * dt_int)
3272
3262
OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
3273
- @. . broadcast= false linsolve_tmps[1 ]= dt_int * k
3263
+ @. . broadcast= false linsolve_tmps[1 ]= k
3274
3264
3275
3265
linsolve = cache. linsolve[1 ]
3276
3266
if ! repeat_step && j == 1
@@ -3283,8 +3273,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3283
3273
cache. linsolve[1 ] = linres. cache
3284
3274
3285
3275
integrator. stats. nsolve += 1
3286
- @. . broadcast= false k= - k
3287
- @. . broadcast= false T[i + 1 ]= u_temp1 + k
3276
+ @. . broadcast= false T[i + 1 ]= u_temp1 - k
3288
3277
if (j == j_int + 1 )
3289
3278
@. . broadcast= false T[i + 1 ]= 0.25 (T[i + 1 ] + 2 * u_temp1 + u_temp2)
3290
3279
end
@@ -3323,7 +3312,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3323
3312
j_int_temp = sequence_factor * subdividing_sequence[index + 1 ]
3324
3313
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
3325
3314
jacobian2W! (W[Threads. threadid ()], integrator. f. mass_matrix,
3326
- dt_int_temp, J, false )
3315
+ dt_int_temp, J, true )
3327
3316
@. . broadcast= false u_temp4[Threads. threadid ()]= uprev
3328
3317
@. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
3329
3318
fsalfirst
@@ -3414,7 +3403,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3414
3403
j_int_temp = sequence_factor * subdividing_sequence[index + 1 ]
3415
3404
dt_int_temp = dt / j_int_temp # Stepsize of the ith internal discretisation
3416
3405
jacobian2W! (W[Threads. threadid ()], integrator. f. mass_matrix,
3417
- dt_int_temp, J, false )
3406
+ dt_int_temp, J, true )
3418
3407
@. . broadcast= false u_temp4[Threads. threadid ()]= uprev
3419
3408
@. . broadcast= false linsolve_tmps[Threads. threadid ()]= dt_int_temp *
3420
3409
fsalfirst
@@ -3548,7 +3537,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC
3548
3537
# Update cache.T
3549
3538
j_int = sequence_factor * subdividing_sequence[n_curr + 1 ]
3550
3539
dt_int = dt / j_int # Stepsize of the new internal discretisation
3551
- jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, false )
3540
+ jacobian2W! (W[1 ], integrator. f. mass_matrix, dt_int, J, true )
3552
3541
integrator. stats. nw += 1
3553
3542
@. . broadcast= false u_temp2= uprev
3554
3543
@. . broadcast= false linsolve_tmps[1 ]= dt_int * fsalfirst
0 commit comments