@@ -453,14 +453,20 @@ end subroutine get_finite_diff_formula
453
453
! * \( (-f(x-3h)+6f(x-2h)-18f(x-h)+10f(x)+3f(x+h)) / (12h) \)
454
454
! * \( (-25f(x)+48f(x+h)-36f(x+2h)+16f(x+3h)-3f(x+4h)) / (12h) \)
455
455
! * \( (3f(x-4h)-16f(x-3h)+36f(x-2h)-48f(x-h)+25f(x)) / (12h) \)
456
+ ! * \( (3f(x-2h)-30f(x-h)-20f(x)+60f(x+h)-15f(x+2h)+2f(x+3h)) / (60h) ])
457
+ ! * \( (-2f(x-3h)+15f(x-2h)-60f(x-h)+20f(x)+30f(x+h)-3f(x+2h)) / (60h) ])
458
+ ! * \( (-12f(x-h)-65f(x)+120f(x+h)-60f(x+2h)+20f(x+3h)-3f(x+4h)) / (60h) ])
459
+ ! * \( (3f(x-4h)-20f(x-3h)+60f(x-2h)-120f(x-h)+65f(x)+12f(x+h)) / (60h) ])
460
+ ! * \( (-137f(x)+300f(x+h)-300f(x+2h)+200f(x+3h)-75f(x+4h)+12f(x+5h)) / (60h) ])
461
+ ! * \( (-12f(x-5h)+75f(x-4h)-200f(x-3h)+300f(x-2h)-300f(x-h)+137f(x)) / (60h) ])
456
462
!
457
463
! Where \(f(x)\) is the user-defined function of \(x\)
458
464
! and \(h\) is a "small" perturbation.
459
465
!
460
466
! @note This is the only routine that has to be changed if a new
461
467
! finite difference method is added.
462
468
!
463
- ! @note The order within a class is assumed to be the order that we would perfer
469
+ ! @note The order within a class is assumed to be the order that we would prefer
464
470
! to use them (e.g., central diffs are first, etc.) This is used in
465
471
! the [[select_finite_diff_method]] routine.
466
472
@@ -469,7 +475,8 @@ subroutine get_finite_difference_method(id,fd,found)
469
475
implicit none
470
476
471
477
integer ,intent (in ) :: id ! ! the id code for the method
472
- type (finite_diff_method),intent (out ) :: fd ! ! this method (can be used in [[compute_jacobian]])
478
+ type (finite_diff_method),intent (out ) :: fd ! ! this method (can be used
479
+ ! ! in [[compute_jacobian]])
473
480
logical ,intent (out ) :: found ! ! true if it was found
474
481
475
482
found = .true.
@@ -517,6 +524,24 @@ subroutine get_finite_difference_method(id,fd,found)
517
524
case (14 )
518
525
! (3f(x-4h)-16f(x-3h)+36f(x-2h)-48f(x-h)+25f(x)) / (12h)
519
526
fd = finite_diff_method(id,' 5-point backward 1' , 5 ,[- 4 ,- 3 ,- 2 ,- 1 ,0 ],[3 ,- 16 ,36 ,- 48 ,25 ],12 )
527
+ case (15 )
528
+ ! (3f(x-2h)-30f(x-h)-20f(x)+60f(x+h)-15f(x+2h)+2f(x+3h)) / (60h)
529
+ fd = finite_diff_method(id,' 6-point forward 3' , 6 ,[- 2 ,- 1 ,0 ,1 ,2 ,3 ],[3 ,- 30 ,- 20 ,60 ,- 15 ,2 ],60 )
530
+ case (16 )
531
+ ! (-2f(x-3h)+15f(x-2h)-60f(x-h)+20f(x)+30f(x+h)-3f(x+2h)) / (60h)
532
+ fd = finite_diff_method(id,' 6-point backward 3' , 6 ,[- 3 ,- 2 ,- 1 ,0 ,1 ,2 ],[- 2 ,15 ,- 60 ,20 ,30 ,- 3 ],60 )
533
+ case (17 )
534
+ ! (-12f(x-h)-65f(x)+120f(x+h)-60f(x+2h)+20f(x+3h)-3f(x+4h)) / (60h)
535
+ fd = finite_diff_method(id,' 6-point forward 2' , 6 ,[- 1 ,0 ,1 ,2 ,3 ,4 ],[- 12 ,- 65 ,120 ,- 60 ,20 ,- 3 ],60 )
536
+ case (18 )
537
+ ! (3f(x-4h)-20f(x-3h)+60f(x-2h)-120f(x-h)+65f(x)+12f(x+h)) / (60h)
538
+ fd = finite_diff_method(id,' 6-point backward 2' , 6 ,[- 4 ,- 3 ,- 2 ,- 1 ,0 ,1 ],[3 ,- 20 ,60 ,- 120 ,65 ,12 ],60 )
539
+ case (19 )
540
+ ! (-137f(x)+300f(x+h)-300f(x+2h)+200f(x+3h)-75f(x+4h)+12f(x+5h)) / (60h)
541
+ fd = finite_diff_method(id,' 6-point forward 1' , 6 ,[0 ,1 ,2 ,3 ,4 ,5 ],[- 137 ,300 ,- 300 ,200 ,- 75 ,12 ],60 )
542
+ case (20 )
543
+ ! (-12f(x-5h)+75f(x-4h)-200f(x-3h)+300f(x-2h)-300f(x-h)+137f(x)) / (60h)
544
+ fd = finite_diff_method(id,' 6-point backward 1' , 6 ,[- 5 ,- 4 ,- 3 ,- 2 ,- 1 ,0 ],[- 12 ,75 ,- 200 ,300 ,- 300 ,137 ],60 )
520
545
case default
521
546
found = .false.
522
547
end select
@@ -526,7 +551,8 @@ end subroutine get_finite_difference_method
526
551
527
552
! *******************************************************************************
528
553
! >
529
- ! Returns all the methods with the given `class`.
554
+ ! Returns all the methods with the given `class`
555
+ ! (i.e., number of points in the formula).
530
556
531
557
function get_all_methods_in_class (class ) result(list_of_methods)
532
558
@@ -795,14 +821,12 @@ subroutine set_numdiff_bounds(me,xlow,xhigh)
795
821
else if (any (xlow>= xhigh)) then
796
822
error stop ' Error: all xlow must be < xhigh'
797
823
else
798
-
799
824
if (allocated (me% xlow)) deallocate (me% xlow)
800
825
if (allocated (me% xhigh)) deallocate (me% xhigh)
801
826
allocate (me% xlow(me% n))
802
827
allocate (me% xhigh(me% n))
803
828
me% xlow = xlow
804
829
me% xhigh = xhigh
805
-
806
830
end if
807
831
808
832
end subroutine set_numdiff_bounds
0 commit comments