ESPUTR
calculation of sputtering yields
esputr_YN.cpp
Go to the documentation of this file.
1 
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 
25 #include <octave/oct.h>
26 #include <cstring>
27 #include <string>
28 #include "esputr_octave.hpp"
29 
30 DEFUN_DLD (esputr_YN, args, nargout,
31 "\n\
32  Calculate sputtering yields for normal incidence (interface to ESPUTR)\n\
33 \n\
34  [Y1 Y2 ...] = esputr_YN(E0, proj, targ, version, fileN)\n\
35 \n\
36  Y1, Y2 ... : row vectors of sputtering yields - \n\
37  - one vector for each projectile-target combination \n\
38  E0 : row vector of the projectile energies, eV \n\
39  proj : column vector of the projectile names \n\
40  targ : column vector of the target names \n\
41  version : designation of the model ('1993' or '2001') \n\
42  fileN : name of the file (full path) with fitting parameters \n\
43 \n\
44  If the lengths of proj and targ differ, the last element of the shorter vector is repeated \n\
45 \n\
46  Examples: \n\
47 \n\
48  D on Be, 2007 model (2001 with coefficients from [Eckstein 2007]) \n\
49  y = esputr_YN([[0:10:200],[2000:1000:10000]], 'D', 'Be', '2001', '../data/ECKSTEIN2007N') \n\
50 \n\
51  D/T on Be and Be on Be, 1993-model (old EIRENE) \n\
52  [D_Be,T_Be,Be_Be] = esputr_YN([10,100,3000],strvcat('D','T','self'), 'Beryllium', '1993', '../data/SPUTER') \n\
53 \n\
54  H on Be, D on C, T on Mo, 2007 model \n\
55  [H_Be,D_C,T_Mo] = esputr_YN([10,100,3000], strvcat('H','D','T'), strvcat('Be','C ','Mo'), '2001', '../data/ECKSTEIN2007N')") {
56  octave_value_list retval;
57  int nargin = args.length();
58 
59  if(nargin != 5) {
60  error("5 input arguments required");
61  //vk print_usage();
62  } else {
63  NDArray E0s = args(0).array_value();
64  if(!error_state) {
65  double* E0s_v = E0s.fortran_vec();
66  octave_idx_type n_E0s = E0s.numel();
67 
68  charMatrix projs = args(1).char_matrix_value();
69  octave_idx_type n_projs = projs.rows();
70  charMatrix targs = args(2).char_matrix_value();
71  octave_idx_type n_targs = targs.rows();
72 
73  octave_idx_type n_combinations = std::max(n_projs, n_targs);
74 
75  std::string version_str = args(3).char_matrix_value().row_as_string(0);
76  const char* version = version_str.c_str();
77  octave_idx_type version_length = version_str.length();
78 
79  std::string fileN = args(4).char_matrix_value().row_as_string(0);
80 
81  int err = 0;
82 
83  if(error_state) {
84  error("sth went wrong");
85  }
86 
87 
88 
89  if(version_str == "1993") {
90  F77_XFCN(esputr1993_init_wrapper, FORTSUB, (fileN.c_str(), err, fileN.length()));
91  } else if(version_str == "2001") {
92  F77_XFCN(esputr2001_initn_wrapper, FORTSUB, (fileN.c_str(), err, fileN.length()));
93  } else {
94  error("unknown model");
95  F77_XFCN(esputr_deallocate, FORTSUB, (err));
96  return retval;
97  }
98  if(err != 0) {
99  error("error during initialization of ESPUTR");
100  F77_XFCN(esputr_deallocate, FORTSUB, (err));
101  return retval;
102  }
103 
104  for(int c = 0; c < n_combinations; c++) {
105  std::string proj = projs.row_as_string(std::min(c, n_projs-1));
106  std::string targ = targs.row_as_string(std::min(c, n_targs-1));
107  Matrix YNs (1, n_E0s);
108  F77_XFCN(esputr_yn, FORTSUB,
109  (E0s_v, n_E0s,
110  proj.c_str(),
111  targ.c_str(),
112  version,
113  YNs.fortran_vec(),
114  err
115  F77_CHAR_ARG_LEN(proj.length())
116  F77_CHAR_ARG_LEN(targ.length())
117  F77_CHAR_ARG_LEN(version_length)
118  ));
119  if(err != 0) {
120  error("error in esputr_matlab_yn");
121  F77_XFCN(esputr_deallocate, FORTSUB, (err));
122  return retval;
123  }
124  retval(c) = YNs;
125  }
126 
127  F77_XFCN(esputr_deallocate, FORTSUB, (err));
128  }
129  }
130  return retval;
131 }
subroutine esputr_deallocate(err)
call esputr2001_deallocate and esputr1993_deallocate
DEFUN_DLD(esputr_YN, args, nargout,"\n\ Calculate sputtering yields for normal incidence (interface to ESPUTR)\n\ \n\ [Y1 Y2 ...] = esputr_YN(E0, proj, targ, version, fileN)\n\ \n\ Y1, Y2 ... : row vectors of sputtering yields - \n\ - one vector for each projectile-target combination \n\ E0 : row vector of the projectile energies, eV \n\ proj : column vector of the projectile names \n\ targ : column vector of the target names \n\ version : designation of the model ('1993' or '2001') \n\ fileN : name of the file (full path) with fitting parameters \n\ \n\ If the lengths of proj and targ differ, the last element of the shorter vector is repeated \n\ \n\ Examples: \n\ \n\ D on Be, 2007 model (2001 with coefficients from [Eckstein 2007]) \n\ y = esputr_YN([[0:10:200],[2000:1000:10000]], 'D', 'Be', '2001', '../data/ECKSTEIN2007N') \n\ \n\ D/T on Be and Be on Be, 1993-model (old EIRENE) \n\ [D_Be,T_Be,Be_Be] = esputr_YN([10,100,3000],strvcat('D','T','self'), 'Beryllium', '1993', '../data/SPUTER') \n\ \n\ H on Be, D on C, T on Mo, 2007 model \n\ [H_Be,D_C,T_Mo] = esputr_YN([10,100,3000], strvcat('H','D','T'), strvcat('Be','C ','Mo'), '2001', '../data/ECKSTEIN2007N')")
Definition: esputr_YN.cpp:30
integer, parameter n_combinations
Number of tested projectile-target combinations.
subroutine esputr1993_init_wrapper(fileN, err)
See include esputr_octave.hpp, esputr_YN.cpp, esputr_YTH.cpp as an example of how to use those subrou...
subroutine esputr_yn(E0s, n_E0s, proj, targ, version, YNs, err)
Calculate sputtering yield for normal incidence for selected incident energies and the specified proj...
subroutine esputr2001_initn_wrapper(fileN, err)
module-less wraper for esputr2001_initN