ESPUTR
calculation of sputtering yields
esputr1993_test.f90
Go to the documentation of this file.
1 
5 
6 ! Copyright (c) 2016 Forschungszentrum Juelich GmbH
7 ! Markus Brenneis, Vladislav Kotov
8 !
9 ! This file is part of ESPUTR.
10 !
11 ! ESPUTR is free software: you can redistribute it and/or modify
12 ! it under the terms of the GNU General Public License as published by
13 ! the Free Software Foundation, either version 3 of the License, or
14 ! (at your option) any later version.
15 !
16 ! ESPUTR is distributed in the hope that it will be useful,
17 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ! GNU General Public License for more details.
20 !
21 ! You should have received a copy of the GNU General Public License
22 ! along with ESPUTR. If not, see <http://www.gnu.org/licenses/>.
23 !
24 
26  use esputr
27  use esputr1993
28  use esputr_test
29 
30  implicit none
34  public esputr1993_test_th
39  public esputr1993_test_eth
41 
42  private
43 
44  integer :: i_
46  character(*), parameter :: sputer1993_fitvalues_file = "../data/SPUTER"
48  integer, parameter :: n_e0 = 38
50  integer, parameter :: n_combinations = 8
52  real(kind=ESPUTR_DP), dimension(N_E0), parameter :: e0 = (/ (i_, i_=0,200,10), (i_, i_=300,900,100), (i_, i_=1000,10000,1000) /)
54  character(10), dimension(3, N_COMBINATIONS), parameter :: combinations = reshape (&
55  (/ &
56  "D ", "Be ", "Beryllium ", &
57  "T ", "Be ", "Beryllium ", &
58  "D ", "Fe ", "Iron ", &
59  "T ", "Fe ", "Iron ", &
60  "D ", "Mo ", "Molybdenum", &
61  "T ", "Mo ", "Molybdenum", &
62  "D ", "W ", "Tungsten ", &
63  "T ", "W ", "Tungsten " &
64  /), (/ 3, n_combinations/) )
65 
67  real(kind=ESPUTR_DP), dimension(N_E0, N_COMBINATIONS), parameter :: expected1993 = reshape (&
68  (/ &
69  ! D->Be
70  0.000000000e+00, 0.000000000e+00, 1.104103489e-03, 5.412871941e-03, 9.865317449e-03, &
71  1.362015231e-02, 1.666145691e-02, 1.911097532e-02, 2.109086932e-02, 2.270029556e-02, &
72  2.401582971e-02, 2.509606869e-02, 2.598604652e-02, 2.672069140e-02, 2.732738324e-02, &
73  2.782781747e-02, 2.823936384e-02, 2.857606414e-02, 2.884937187e-02, 2.906870654e-02, &
74  2.924187358e-02, 2.947274709e-02, 2.854958532e-02, 2.733847992e-02, 2.609905503e-02, &
75  2.491692942e-02, 2.381836251e-02, 2.280755068e-02, 2.188037090e-02, 1.574763130e-02, &
76  1.251330226e-02, 1.048765264e-02, 9.084401421e-03, 8.047182373e-03, 7.245108871e-03, &
77  6.603895290e-03, 6.078020749e-03, 5.637921894e-03, &
78  ! T->Be
79  0.000000000e+00, 0.000000000e+00, 6.163481396e-04, 4.972985113e-03, 1.020839541e-02, &
80  1.488585322e-02, 1.880155249e-02, 2.202962229e-02, 2.468817158e-02, 2.688523383e-02, &
81  2.870915201e-02, 3.022989306e-02, 3.150250386e-02, 3.257042361e-02, 3.346816812e-02, &
82  3.422339168e-02, 3.485844337e-02, 3.539153839e-02, 3.583764297e-02, 3.620914723e-02, &
83  3.651638116e-02, 3.744791982e-02, 3.664606240e-02, 3.533663840e-02, 3.390936958e-02, &
84  3.250448541e-02, 3.117319558e-02, 2.993157952e-02, 2.878118075e-02, 2.097715208e-02, &
85  1.676289492e-02, 1.409672877e-02, 1.223877094e-02, 1.085992900e-02, 9.790536375e-03, &
86  8.933666020e-03, 8.229639207e-03, 7.639555433e-03, &
87  ! D->Fe
88  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 1.737185437e-04, &
89  1.046539046e-03, 2.422094274e-03, 4.030510991e-03, 5.711258056e-03, 7.379122837e-03, &
90  8.991161166e-03, 1.052732180e-02, 1.197988020e-02, 1.334770838e-02, 1.463313703e-02, &
91  1.584021883e-02, 1.697376134e-02, 1.803879011e-02, 1.904025543e-02, 1.998287882e-02, &
92  2.087107955e-02, 2.750974373e-02, 3.158309658e-02, 3.425578892e-02, 3.608011706e-02, &
93  3.735185130e-02, 3.824445425e-02, 3.886676439e-02, 3.929068098e-02, 3.899753173e-02, &
94  3.659592588e-02, 3.413323981e-02, 3.191246470e-02, 2.996087981e-02, 2.825036739e-02, &
95  2.674482709e-02, 2.541138231e-02, 2.422248563e-02, &
96  ! T->Fe
97  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 2.748668824e-04, 1.978833967e-03, &
98  4.540618007e-03, 7.352042125e-03, 1.013825575e-02, 1.278839828e-02, 1.526410109e-02, &
99  1.755873052e-02, 1.967924827e-02, 2.163797159e-02, 2.344878690e-02, 2.512542918e-02, &
100  2.668074192e-02, 2.812640767e-02, 2.947290264e-02, 3.072955382e-02, 3.190463841e-02, &
101  3.300549564e-02, 4.106738031e-02, 4.588454289e-02, 4.898419565e-02, 5.105844087e-02, &
102  5.247045440e-02, 5.343087730e-02, 5.407097567e-02, 5.447706650e-02, 5.327729815e-02, &
103  4.976522363e-02, 4.631552934e-02, 4.324915487e-02, 4.057314004e-02, 3.823704097e-02, &
104  3.618611411e-02, 3.437278813e-02, 3.275805393e-02, &
105  ! D->Mo
106  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
107  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 6.113259122e-06, &
108  7.256358164e-05, 2.328358848e-04, 4.843020824e-04, 8.127826662e-04, 1.202061715e-03, &
109  1.637256384e-03, 2.105787324e-03, 2.597431521e-03, 3.104056130e-03, 3.619274123e-03, &
110  4.138114139e-03, 9.004279744e-03, 1.287372049e-02, 1.586171980e-02, 1.819622945e-02, &
111  2.005041866e-02, 2.154526339e-02, 2.276543450e-02, 2.377136679e-02, 2.807671072e-02, &
112  2.860035619e-02, 2.811293568e-02, 2.729748580e-02, 2.638574083e-02, 2.546821410e-02, &
113  2.458203050e-02, 2.374178809e-02, 2.295196529e-02, &
114  ! T->Mo
115  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
116  0.000000000e+00, 3.483440885e-06, 1.336728845e-04, 5.030419358e-04, 1.081139055e-03, &
117  1.810072022e-03, 2.638605804e-03, 3.527705732e-03, 4.449189325e-03, 5.383205890e-03, &
118  6.315982847e-03, 7.238094468e-03, 8.143200825e-03, 9.027147694e-03, 9.887328317e-03, &
119  1.072223098e-02, 1.769168653e-02, 2.265536772e-02, 2.629792875e-02, 2.905732991e-02, &
120  3.120086984e-02, 3.289801991e-02, 3.426108595e-02, 3.536748555e-02, 3.971780570e-02, &
121  3.979104264e-02, 3.878776201e-02, 3.747362096e-02, 3.610013916e-02, 3.476071376e-02, &
122  3.349023361e-02, 3.229963977e-02, 3.118960080e-02, &
123  ! D->W
124  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
125  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
126  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
127  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
128  0.000000000e+00, 3.821267303e-04, 1.685035389e-03, 3.317431861e-03, 4.955715436e-03, &
129  6.486075150e-03, 7.877297587e-03, 9.129000154e-03, 1.025163704e-02, 1.691922670e-02, &
130  1.966598612e-02, 2.092588409e-02, 2.148623487e-02, 2.167495227e-02, 2.165167616e-02, &
131  2.150239271e-02, 2.127675440e-02, 2.100489733e-02, &
132  ! T->W
133  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
134  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, &
135  0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 0.000000000e+00, 2.818904489e-07, &
136  1.177025344e-05, 5.166389668e-05, 1.273855286e-04, 2.403441647e-04, 3.888649309e-04, &
137  5.698063547e-04, 3.414252549e-03, 6.724809397e-03, 9.761714767e-03, 1.240583179e-02, &
138  1.468313276e-02, 1.664705632e-02, 1.834942033e-02, 1.983412462e-02, 2.803833028e-02, &
139  3.109099865e-02, 3.232680327e-02, 3.273624940e-02, 3.271953512e-02, 3.246788833e-02, &
140  3.208271143e-02, 3.162164526e-02, 3.111906787e-02 /), (/ n_e0, n_combinations /) )
141 
142  contains
143 
145  logical function esputr1993_test_wrong_file()
146  integer, dimension(4) :: err
147  call esputr1993_init("/__FOO_test_wrong_file_1993", err(1))
148  call esputr1993_deallocate(err(2))
149  call esputr1993_init("../data/ECKSTEIN2007N" , err(3))
150  call esputr1993_deallocate(err(4))
151  print *, "esputr1993_test_wrong_file:", err
152  esputr1993_test_wrong_file = all(err(:) == (/300, 0, 300, 0/))
153  end function esputr1993_test_wrong_file
154 
156  logical function esputr1993_test_wrong_ids()
157  integer, dimension(6) :: err
158  real(kind=ESPUTR_DP) :: crap
160  crap = esputr1993_yn(0.d0, 2, -42, err(2))
161  crap = esputr1993_yn(0.d0, -42, 2, err(3))
162  crap = esputr1993_yn(0.d0, 2, 1337, err(4))
163  crap = esputr1993_yn(0.d0, 1337, 2, err(5))
164  call esputr1993_deallocate(err(6))
165  print *, "esputr1993_test_wrong_ids:", err
166  esputr1993_test_wrong_ids = all(err == (/0, 100, 100, 100, 100, 0/))
167  end function esputr1993_test_wrong_ids
168 
170  logical function esputr1993_test_double_init()
171  integer, dimension(5) :: err
173  call esputr1993_init("Foo", err(2))
174  call esputr1993_deallocate(err(3))
176  call esputr1993_deallocate(err(5))
177  print *, "esputr1993_test_double_init:", err
178  esputr1993_test_double_init = all(err == (/0, 100, 0, 0, 0/))
179  end function esputr1993_test_double_init
180 
182  logical function esputr1993_test_call_uninitialized()
183  integer, dimension(3) :: err
184  integer :: icrap
185  real(kind=ESPUTR_DP) :: rcrap
186  icrap = esputr1993_getprojectileid("D", err(1))
187  icrap = esputr1993_gettargetid("Beryllium", err(2))
188  rcrap = esputr1993_yn(0.d0, 1, 1, err(3))
189  print *, "esputr1993_test_call_uninitialized:", err
190  esputr1993_test_call_uninitialized = all(err == 50)
192 
194  logical function esputr1993_test_unknown_elements()
195  integer, dimension(4) :: err
196  integer :: icrap
198  icrap = esputr1993_getprojectileid("Ä", err(2))
199  icrap = esputr1993_gettargetid("Ä", err(3))
200  call esputr1993_deallocate(err(4))
201  print *, "esputr1993_test_unknown_elements:", err
202  esputr1993_test_unknown_elements = all(err == (/0, 101, 102, 0/))
204 
206  logical function esputr1993_test_wrong_angle()
207  integer, dimension(5) :: err
208  real(kind=ESPUTR_DP) :: crap
210  crap = esputr1993_yth(-.1d0, err(2))
211  crap = esputr1993_yth(1.6d0, err(3))
212  crap = esputr1993_yth(0.6d0, err(4))
213  call esputr1993_deallocate(err(5))
214  print *, "esputr1993_test_wrong_angle", err
215  esputr1993_test_wrong_angle = all(err == (/0, 103, 103, 0, 0/))
216  end function esputr1993_test_wrong_angle
217 
219  logical function esputr1993_test_compare()
220  logical, dimension(N_COMBINATIONS) :: results
221  integer :: i,err
223  if (err /=0 ) then
224  print *, "FAILURE in esputr1993_test_compare: unexpected err value", err
225  esputr1993_test_compare = .false.
226  return
227  end if
228  do i = 1, n_combinations
229  results(i) = test_1993(expected1993(:,i), combinations(1,i), combinations(3,i))
230  end do
231  call esputr1993_deallocate(err)
232  if (err /=0 ) then
233  print *, "FAILURE in esputr1993_test_compare: unexpected err value", err
234  esputr1993_test_compare = .false.
235  return
236  end if
237  print *, "esputr1993_test_compare: ", results
238  esputr1993_test_compare = all(results)
239 
240  contains
241 
244  logical function test_1993(expected, proj, targ)
245  real(kind=ESPUTR_DP), dimension(N_E0), intent(in) :: expected
246  character(*), intent(in) :: proj, targ
247  integer :: projId, targId, err
248  real(kind=ESPUTR_DP), dimension(N_E0) :: Y
249  logical, dimension(N_E0) :: passed
250  integer :: i
251 
252  projid = esputr1993_getprojectileid(proj,err)
253  if(err /= 0) goto 1000
254  targid = esputr1993_gettargetid(targ,err)
255  if(err /= 0) goto 1000
256  do i = 1, n_e0
257  y(i) = esputr1993_yn(e0(i), projid, targid, err)
258  if(err /= 0) goto 1000
259  end do
260 
261  ! Compare calculated Y with the reference 'expected'
262  passed = ispassed(expected, y)
263  call printfailed(expected, y, passed)
264  test_1993 = all(passed)
265  return
266 1000 print *, "FAILURE in esputr1993_test_compare: unexpected err value", err
267  test_1993 = .false.
268  return
269  end function test_1993
270  end function esputr1993_test_compare
271 
277  logical function esputr1993_test_th()
278  real(kind=ESPUTR_DP) :: Y
279  integer :: err
280  real(kind=ESPUTR_DP), parameter :: TH_OPT = 75.*esputr_pi/180., y_th_opt = 3.390205
282  if(err /= 0) goto 2500
283  y = esputr1993_yth(0d0, err)
284  if(err /= 0) goto 2500
285  if(.not.ispassed(y,1.0d0)) then
286  print *, "FAILURE in esputr1993_test_TH: expected 1, got ", y
287  goto 1500
288  end if
289  y = esputr1993_yth(th_opt, err)
290  if(err /= 0) goto 2500
291  if(.not.ispassed(y,y_th_opt)) then
292  print *, "FAILURE in esputr1993_test_TH: expected", y_th_opt, ", got ", y
293  goto 1500
294  end if
295  y = esputr1993_yth(esputr_pi/2, err)
296  if(err /= 0) goto 2500
297  if(.not.ispassed(y,0.d0)) then
298  print *, "FAILURE in esputr1993_test_TH: expected", 0., ", got ", y
299  goto 1500
300  end if
301  if(err /= 0) goto 2500
302  call esputr1993_deallocate(err)
303  if(err /= 0) goto 2500
304  print *, "esputr1993_test_1993_TH:", .true.
305  esputr1993_test_th = .true.
306  return
307 2500 print *, "FAILURE in esputr1993_test_TH: unexpected err value", err
308 1500 esputr1993_test_th = .false.
309  call esputr1993_deallocate(err)
310  return
311  end function esputr1993_test_th
312 
314  logical function esputr1993_test_eth()
315  integer :: err, proj_id, targ_id
316  real(kind=ESPUTR_DP) :: Eth
317  esputr1993_test_eth = .false.
319  if(err /= 0) goto 5100
320  proj_id = esputr1993_getprojectileid("H", err)
321  if(err /= 0) goto 5100
322  targ_id = esputr1993_gettargetid("Lithium", err)
323  if(err /= 0) goto 5100
324  eth = esputr1993_eth(proj_id, targ_id, err)
325  if(err /= 0) goto 5100
326  if(ispassed(eth, 6.22d0)) then
327  esputr1993_test_eth = .true.
328  else
329  print *, "FAILURE in esputr1993_test_ETH: ", eth
330  end if
331  call esputr1993_deallocate(err)
332  if(err /= 0) goto 5100
333  return
334 5100 print *, "FAILURE in esputr1993_test_ETH: unexpected err value", err
335  call esputr1993_deallocate(err)
336  end function esputr1993_test_eth
337 
339  logical function esputr1993_test_initialized()
340  integer :: err
341  logical :: initialized
343  initialized = esputr1993_if_initialized()
344  if(initialized) goto 7100
345  call esputr1993_init("../data/ECKSTEIN2007", err)
346  if(err == 0) goto 7100
347  initialized = esputr1993_if_initialized()
348  if(initialized) goto 7100
350  if(err /= 0) goto 7100
351  initialized = esputr1993_if_initialized()
352  if(.not. initialized) goto 7100
353  call esputr1993_deallocate(err)
354  if(err /= 0) goto 7100
356  return
357 7100 print *, "FAILURE in esputr1993_test_initialized"
358  call esputr1993_deallocate(err)
359  end function esputr1993_test_initialized
360 
361 end module esputr1993_test
362 
363 program test1993
364  use esputr1993_test
365  use esputr
366  implicit none
367 
368  esputr_unit = 0
369 
370  if(.not.esputr1993_test_wrong_file()) stop " ERROR detected in esputr1993_test_wrong_file"
371  if(.not.esputr1993_test_wrong_ids()) stop " ERROR detected in esputr1993_test_wrong_ids"
372  if(.not.esputr1993_test_double_init()) stop " ERROR detected in esputr1993_test_double_init"
373  if(.not.esputr1993_test_call_uninitialized()) stop " ERROR detected in esputr1993_test_call_uninitialized"
374  if(.not.esputr1993_test_unknown_elements()) stop " ERROR detected in esputr1993_test_unknown_elements"
375  if(.not.esputr1993_test_wrong_angle()) stop " ERROR detected in esputr1993_test_wrong_angle"
376  if(.not.esputr1993_test_compare()) stop " ERROR detected in esputr1993_test_compare"
377  if(.not.esputr1993_test_th()) stop " ERROR detected in esputr1993_test_TH"
378  if(.not.esputr1993_test_eth()) stop " ERROR detected in esputr1993_test_ETH"
379  if(.not.esputr1993_test_initialized()) stop " ERROR detected in esputr1993_test_initialized"
380  print *, "ESPUTR1993_TEST COMPLETED"
381 end program test1993
real(esputr_dp) function, public esputr1993_yn(E0, proj_id, targ_id, err)
Calculate sputtering yield for normal incidence with 1993-model for a given incident energy and targe...
Definition: esputr1993.f90:417
integer function, public esputr1993_getprojectileid(proj, err)
Return ID of the projectile for the 1993-model.
Definition: esputr1993.f90:352
logical function, public esputr1993_test_call_uninitialized()
Test for correct error codes if functions are used w/o initialization of the module.
logical function, public esputr1993_test_eth()
Check esputr1993_Eth.
subroutine, public esputr1993_deallocate(err)
Deallocate dynamic arrays used by the module ESPUTR1993.
Definition: esputr1993.f90:329
subroutine, public printfailed(expected, calculated, passed)
Print pairs of values (expected(i),calculated(i)) for which passed(i)=.false.
Definition: esputr_test.f90:51
integer, parameter n_e0
Number of tested values of incident energy.
character(10), dimension(3, n_combinations), parameter combinations
List of projectile-target combinations for which the reference values are defined.
logical function, public esputr1993_test_th()
Check the angular dependence.
subroutine, public esputr1993_init(constantsFile, err)
Initialization of the 1993-model.
Definition: esputr1993.f90:82
logical function, public esputr1993_test_initialized()
Check esputr1993_if_initialized.
real(esputr_dp), parameter, public esputr_pi
Pi number.
Definition: esputr.f90:79
logical elemental function, public ispassed(expected, calculated)
Definition: esputr_test.f90:39
integer, parameter n_combinations
Number of tested projectile-target combinations.
program test1993
logical function, public esputr1993_test_unknown_elements()
Test for correct error codes if ID of an unknown species is requested.
character(*), parameter sputer1993_fitvalues_file
Default path to the input file.
logical function, public esputr1993_test_double_init()
Test for correct error codes if 1993 model is initialized or deallocateted more than once...
integer function, public esputr1993_gettargetid(targ, err)
Return ID of the target for the 1993-model.
Definition: esputr1993.f90:382
real(esputr_dp) function, public esputr1993_yth(theta, err)
Angular dependence of sputtering yield in 1993-model for given incident angle.
Definition: esputr1993.f90:468
real(kind=esputr_dp), dimension(n_e0, n_combinations), parameter expected1993
Reference values for comparison.
logical function, public esputr1993_test_wrong_angle()
Test for correct error codes if incident angle is out of bounds.
logical function, public esputr1993_test_wrong_ids()
Test for correct error codes if projectile/target IDs do not exist.
real(kind=esputr_dp), dimension(n_e0), parameter e0
Values of incident energy for which the yields are tested (eV)
logical function, public esputr1993_if_initialized()
Return .true. if module esputr1993 is initialized.
Definition: esputr1993.f90:259
logical function, public esputr1993_test_wrong_file()
Test for correct error codes if given file does not exist or is corrupted.
integer, save, public esputr_unit
Index of the unit for standard output, default value 6.
Definition: esputr.f90:73
real(esputr_dp) function, public esputr1993_eth(proj_id, targ_id, err)
Return threshold energy for the given projectile-target combination.
Definition: esputr1993.f90:505
logical function, public esputr1993_test_compare()
Test that expected values come out of esputr1993_yn.