@@ -19,8 +19,7 @@ module subdomain_2D_m
1919 real , allocatable :: s_(:,:)
2020 contains
2121 procedure define
22- procedure dx
23- procedure dy
22+ procedure dt_stable
2423 procedure values
2524 procedure exchange_halo
2625 generic :: operator (.laplacian.) = > laplacian
@@ -44,16 +43,11 @@ pure module function values(self) result(my_values)
4443 real , allocatable :: my_values(:,:)
4544 end function
4645
47- pure module function dx (self) result(my_dx )
46+ pure module function dt_stable (self, alpha ) result(my_dt )
4847 implicit none
4948 class(subdomain_2D_t), intent (in ) :: self
50- real my_dx
51- end function
52-
53- pure module function dy(self) result(my_dy)
54- implicit none
55- class(subdomain_2D_t), intent (in ) :: self
56- real my_dy
49+ real , intent (in ) :: alpha
50+ real my_dt
5751 end function
5852
5953 pure module function laplacian(rhs) result(laplacian_rhs)
@@ -118,12 +112,11 @@ module subroutine exchange_halo(self)
118112 call self% exchange_halo
119113 end procedure
120114
121- module procedure dx
122- my_dx = dx_
123- end procedure
124-
125- module procedure dy
126- my_dy = dy_
115+ module procedure dt_stable
116+ ! ! Set the time step at 90% of the stability limit obtained provided by
117+ ! ! Kassinos, S., & Alexiadis, A. (2024). Beyond Language: Applying MLX Transformers to Engineering Physics
118+ ! ! arXiv preprint arXiv:2410.04167.
119+ my_dt = 0.9 * (1 ./ (1 ./ dx_** 2 + 1 ./ dy_** 2 )) * (1 ./ (2 .* alpha))
127120 end procedure
128121
129122 module procedure laplacian
@@ -192,7 +185,7 @@ program main
192185 call T% define(side= 1 ., boundary_val= T_boundary, internal_val= T_initial, n= nx) ! 2D step function
193186 sync all
194187
195- associate(dt = > T% dx() * T % dy() / ( 4 * alpha))
188+ associate(dt = > T% dt_stable( alpha))
196189 call cpu_time(t_start)
197190 do step = 1 , steps
198191 T = T + dt * alpha * .laplacian. T
0 commit comments