source: PSPA/parmelaPSPA/trunk/geners.f @ 315

Last change on this file since 315 was 12, checked in by lemeur, 12 years ago

parmela pspa initial

File size: 4.8 KB
Line 
1      subroutine geners
2c---generate misalignment errors
3c---------------------------------------------------------------------------
4      save
5c
6      include 'param_sz.h'
7      include 'constcom.h'
8      include 'misccom.h'
9      include 'syscom.h'
10      include 'var_char.h'
11      include 'ucom.h'
12c
13      common/errors/eraln(5,0:lmx)
14c--------------------------------------------------------------------------
15c*
16c---arguments are in array vv. first 3 args are ntype, n1, n2.  ntype
17c---defines the type of misalignment to apply in elements n1 thru n2.
18c---mtype=1, specific displacements of each begining of element are given in
19c---         vv(4) thru vv(7).   (dx1,dy1,dx2,dy2)
20c---mtype=2, random displacements independently in x and y, no tilt.
21c---         tolerances are given in vv(4) and vv(5).  (dx,dy)
22c---mtype=3, random displacements independently in x and y at begining
23c---         of element.  tolerances in vv(4), vv(5).
24c---mtype=4, random displacements independently in x and y at both ends.
25c---         (dx1,dy1,dx2,dy2)
26c---mtype=5, random radial displacement, no tilt.  vv(4)=dr
27c---mtype=6, random radial displacement at end (vv(4)), no initial disp.
28c---mtype=7, random radial displacements at each end.  vv(4), vv(5)
29c---mtype=8, specific displacement and change in direction at begining of
30c---         element are given in vv(4) thru vv(7). (dx1,dy1,theatax1,
31c---         theatay1) change in direction given in degrees.
32c---mtype=9, random radial displacements at begining of element vv(4),
33c---         random angular displacement vv(5), and a maximum total
34c---         radial displacement vv(6). The angular displacement is with
35c---         respect to the orginal axis in units of radians.
36c---         This type only applys errors to non-zero-length elements.
37      mtype=vv(1)
38      n1=vv(2)
39      n2=vv(3)
40      if(mtype.eq.9 .and. (vv(4).ge.vv(6) .or. vv(5).gt.0.1 
41     * .or. n2.ge.nel)) then
42      write(ndiag,*)' bad arguments on errors card'
43      call appendparm
44      stop ' Abnormal stop geners '
45      endif
46      do 100 n=n1,n2
47      eraln(1,n)=mtype
48      if(mtype.eq.9)go to 90
49      do 5 i=2,5
50      eraln(i,n)=0.
51    5 continue
52      go to (10,20,30,40,50,60,70,80),mtype
53   10 continue
54      eraln(2,n)=vv(4)
55      eraln(4,n)=vv(5)
56      if(el(1,n).le.0.)go to 100
57      eraln(3,n)=(vv(6)-vv(4))/el(1,n)
58      eraln(5,n)=(vv(7)-vv(5))/el(1,n)
59      go to 100
60   20 continue
61      eraln(2,n)=2.*vv(4)*(.5-ranf())
62      eraln(4,n)=2.*vv(5)*(.5-ranf())
63      go to 100
64   30 continue
65      if(el(1,n).le.0.)go to 100
66      eraln(3,n)=2.*vv(4)*(.5-ranf())/el(1,n)
67      eraln(5,n)=2.*vv(5)*(.5-ranf())/el(1,n)
68      go to 100
69   40 continue
70      eraln(2,n)=2.*vv(4)*(.5-ranf())
71      eraln(4,n)=2.*vv(5)*(.5-ranf())
72      if(el(1,n).le.0.)go to 100
73      eraln(3,n)=(2.*vv(6)*(.5-ranf())-eraln(2,n))/el(1,n)
74      eraln(5,n)=(2.*vv(7)*(.5-ranf())-eraln(4,n))/el(1,n)
75      go to 100
76   50 continue
77      r=vv(4)*ranf()
78      theta=twopi*ranf()
79      dx=r*cos(theta)
80      dy=r*sin(theta)
81      eraln(2,n)=dx
82      eraln(4,n)=dy
83      go to 100
84   60 continue
85      if(el(1,n).le.0.)go to 100
86      r=vv(4)*ranf()
87      theta=twopi*ranf()
88      eraln(3,n)=r*cos(theta)/el(1,n)
89      eraln(5,n)=r*sin(theta)/el(1,n)
90      go to 100
91   70 continue
92      r=vv(4)*ranf()
93      theta=twopi*ranf()
94      eraln(2,n)=r*cos(theta)
95      eraln(4,n)=r*sin(theta)
96      if(el(1,n).le.0.)go to 100
97      r=vv(5)*ranf()
98      theta=twopi*ranf()
99      eraln(3,n)=(r*cos(theta)-eraln(2,n))/el(1,n)
100      eraln(5,n)=(r*sin(theta)-eraln(4,n))/el(1,n)
101      go to 100
102   80 continue
103      eraln(2,n)=vv(4)
104      eraln(4,n)=vv(5)
105      eraln(3,n)=sin(vv(6)*radian)
106      eraln(5,n)=sin(vv(7)*radian)
107      go to 100
108   90 continue
109      if(n.eq.n1)then
110      xtotal=0.
111      ytotal=0.
112      eraln(3,n)=0.
113      eraln(5,n)=0.
114      eraln(1,n2+1)=mtype
115      endif
116      if(el(1,n).gt.0.)then
117   91   continue
118        r=vv(4)*ranf()
119        theta=twopi*ranf()
120        eraln(2,n)=r*cos(theta)
121        eraln(4,n)=r*sin(theta)
122        if((eraln(2,n)+xtotal)**2+(eraln(4,n)+ytotal)**2.gt.vv(6)**2)
123     *  go to 91
124      xtotal=xtotal+eraln(2,n)
125      ytotal=ytotal+eraln(4,n)
126      else
127        eraln(2,n)=0.
128        eraln(4,n)=0.
129      endif
130      if(el(1,n).gt.0.)then
131   92   continue
132        r=vv(5)*ranf()
133        theta=twopi*ranf()
134        dx=r*cos(theta)
135        dy=r*sin(theta)
136        if((dx*el(1,n)+xtotal)**2+(dy*el(1,n)+ytotal)**2.gt.vv(6)**2)
137     *  go to 92
138      xtotal=xtotal+dx*el(1,n)
139      ytotal=ytotal+dy*el(1,n)
140      eraln(3,n)=dx+eraln(3,n)
141      eraln(5,n)=dy+eraln(5,n)
142      eraln(3,n+1)=-dx
143      eraln(5,n+1)=-dy
144      else
145      eraln(3,n+1)=0.
146      eraln(5,n+1)=0.
147      endif
148        if(n.eq.n2)then
149        eraln(2,n+1)=-xtotal
150        eraln(4,n+1)=-ytotal
151        endif
152  100 continue
153      return
154      end
155c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.