-
Notifications
You must be signed in to change notification settings - Fork 0
/
inread.m
132 lines (114 loc) · 3.38 KB
/
inread.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
%read data from *.in file
%fdin=fopen([nm,'.in'],'r');
%function fieldparmsimport(filename)
fdin=fopen(nm_p,'r');
for lines=1:200
tline = fgetl(fdin);
if ~ischar(tline), break, end
if findstr(tline,'npart')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
npart=sscanf(tline,'%*s%f');
end
if findstr(tline,'ncar')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
M=sscanf(tline,'%*s%f');
end
if findstr(tline,'rxbeam')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
rxbeam=sscanf(tline,'%*s%f');
end
if findstr(tline,'zrayl')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
zrayl=sscanf(tline,'%*s%f');
end
if findstr(tline,'rybeam')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
rybeam=sscanf(tline,'%*s%f');
end
if findstr(tline,'xlamds')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
xlamds=sscanf(tline,'%*s%f');
end
if findstr(tline,'rmax0 ')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
rmax0=sscanf(tline,'%*s%f');
end
if findstr(tline,'dgrid')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
dgrid=sscanf(tline,'%*s%f');
end
if findstr(tline,'nslice')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
nslice=sscanf(tline,'%*s%f');
end
if findstr(tline,'zsep')
k=findstr(tline,'=');
tline(k)=' ';
k=findstr('D',tline);
if ~isempty(k)
tline(k)='E';
end
zsep=sscanf(tline,'%*s%f');
end
if findstr(tline,'$end')
break
end
end
if dgrid==0
rbeam=sqrt(rxbeam^2+rybeam^2);
ray=sqrt(zrayl*xlamds/pi);
leng=rmax0*(rbeam+ray); %%%! *2
else
leng=dgrid*2;
end
clear rxbeam rybeam rbeam ray rmax0
dx=leng/M; dy=dx;
K=2*pi/xlamds;
energy=1239.8/xlamds/1e9;
fclose(fdin);
clear fdin k tline lines