Télécharger b3_v33.eso

Retour à la liste

Numérotation des lignes :

b3_v33
  1. C B3_V33 SOURCE GOUNAND 26/08/19 21:15:01 12620
  2. c**************************************************************************************
  3. subroutine b3_v33(x33,x3,v33)
  4. c A.Sellier jeu. 02 sept. 2010 18:13:24 CEST
  5. c diagonalisagion 33 a partir de jacobi + quelques controles
  6. C Gounand 2026/08 On renvoie sur jacob3.eso, normalement robuste et precise
  7. c declarations externes
  8. implicit real*8(a-h,m-z)
  9. implicit integer(i-l)
  10. real*8 x33(3,3),x3(3),v33(3,3),y33(3,3)
  11. c declarations locales
  12. real*8 epsv,xmax,depsv
  13. integer i,j,k
  14. real*8 un
  15. real*8 eps3(3)
  16. c une matrice est consideree comme deja diagonale si test 20 verifie
  17. c fonction de la prescision relative epsv
  18. c epsv est aussi utilise dans jacob3 pour decider si deux valeurs
  19. c propres petites par rapport a la troisieme peuvent etre consideree
  20. c comme des doubles, ce qui evite de rechercher des vecteurs propres
  21. c avec une matrice mal conditonnee
  22. c enfin epsv est utilise en fin de programme pour tester si la matrice
  23. c de passage fonctionne correctement, pour cela on verifie si la propriete
  24. c vt*v est verifiee a epsv pres hors diagonale si ce n est pas le cas
  25. c on affiche un message non bloquant
  26. parameter(un=1.d0,epsv=1.d-6)
  27. real*8 v33t(3,3)
  28. real*8 u33(3,3),u033(3,3),dif33(3,3)
  29. real*8 xmax1
  30. logical vpmultiple,erreur,diago,ordre
  31. real*8 trace,z3(3),z33(3,3)
  32. integer imax,imin,imed
  33. real*8 zmax,zmin,zmed
  34. C
  35. call jacob3(x33,3,x3,v33)
  36. return
  37. * Old source
  38. c epsv*d(1) valeur en dessous la quelle un terme hors diagonale est negligee
  39. c lors du calcul des vecteurs propres
  40. vpmultiple=.false.
  41. diago=.false.
  42. ordre=.true.
  43. erreur=.false.
  44.  
  45. c print*
  46. c call afic33(x33)
  47. c-----------------------------------------------------------------------
  48. c normalisation du tenseur avant digonalisation
  49. c print*,'avant normalisation ds b3_v33'
  50. c call afic33(x33)
  51. c xmax1=1.0d-8
  52. c do i=1,3
  53. c do j=1,3
  54. c xmax1=dmax1(xmax1,dabs(x33(i,j)))
  55. c end do
  56. c end do
  57. c do i=1,3
  58. c do j=1,3
  59. c x33(i,j)=x33(i,j)/xmax1
  60. c end do
  61. c end do
  62. c print*,'apres normalisation ds b3_v33'
  63. c call afic33(x33)
  64. c-----------------------------------------------------------------------
  65.  
  66. C STOCKAGE de x33 dans y33 pour diagonalisation par jacobi iterative
  67. c car cette methode ecrit sur y33
  68. do i=1,3
  69. do j=1,3
  70. y33(i,j)=x33(i,j)
  71. end do
  72. end do
  73. * call b3_jac(y33,v33,x3)
  74. call dsyevj3(y33,v33,x3)
  75.  
  76. c***********************************************************************
  77. c controle de l ordre des valeurs propres
  78. if((x3(1).gt.x3(2)).and.
  79. # (x3(2).gt.x3(3))) then
  80. continue
  81. else
  82. c on remet de l ordre
  83. trace=0.d0
  84. do i=1,3
  85. z3(i)=x3(i)
  86. trace=trace+z3(i)
  87. do j=1,3
  88. z33(i,j)=v33(i,j)
  89. end do
  90. end do
  91. c on cherche la plus grande valeur propre
  92. imax=1
  93. zmax=z3(imax)
  94. do i=2,3
  95. if(z3(i).gt.zmax) then
  96. imax=i
  97. zmax=z3(i)
  98. end if
  99. end do
  100. c on cherche la plus petite
  101. imin=3
  102. zmin=z3(imin)
  103. do i=2,1,-1
  104. if(z3(i).lt.zmin) then
  105. imin=i
  106. zmin=z3(i)
  107. end if
  108. end do
  109. if (imin.ne.imax) then
  110. c on deduit l intermediaire
  111. zmed=trace-(zmin+zmax)
  112. imed=6-(imin+imax)
  113. c on range correctement
  114. x3(1)=z3(imax)
  115. x3(2)=z3(imed)
  116. x3(3)=z3(imin)
  117. do j=1,3
  118. v33(j,1)=z33(j,imax)
  119. v33(j,2)=z33(j,imed)
  120. v33(j,3)=z33(j,imin)
  121. end do
  122. c on teste si c est bien dans l ordre
  123. C call chre3(z33,y33,v33)
  124. C if( (z33(1,1).lt.z33(2,2)).or.
  125. C # (z33(2,2).lt.z33(3,3)).or.
  126. C # (z33(1,1).lt.z33(3,3)) ) then
  127. C print*,'erreur b3_v33 lors du classement des VP'
  128. C print*,'valeurs propres:'
  129. C do i=1,3
  130. C write(*,'(A2,I1,A2,E10.3)') 'x(',i,')=',x3(i)
  131. C end do
  132. C print*,'matrice a diagonaliser'
  133. C call afic33(y33)
  134. C print*,'matrice de passage'
  135. C call afic33(v33)
  136. C print*,'matrice diagonale'
  137. C call afic33(z33)
  138. C erreur=.true.
  139. C end if
  140. end if
  141. end if
  142. c***********************************************************************
  143.  
  144. c controle des normes de v33
  145. do i=1,3
  146. xn=sqrt(v33(1,i)**2+v33(2,i)**2+v33(3,i)**2)
  147. c print*,'norme v(',i,')=',xn
  148. if(abs(xn-1.d0).gt.1.d-4) then
  149. print*,'vecteur propre anormal ds b3_v33'
  150. call afic33(x33)
  151. c print*,'remplacement par vi v vj'
  152. call indce1(i,k,l)
  153. v33(1,i)=v33(2,k)*v33(3,l)-v33(3,k)*v33(2,l)
  154. v33(2,i)=v33(3,k)*v33(1,l)-v33(1,k)*v33(3,l)
  155. v33(3,i)=v33(1,k)*v33(2,l)-v33(2,k)*v33(1,l)
  156. xn=sqrt(v33(1,i)**2+v33(2,i)**2+v33(3,i)**2)
  157. do k=1,3
  158. v33(k,i)=v33(k,i)/xn
  159. end do
  160. call afic33(v33)
  161. c read*
  162. end if
  163. end do
  164. goto 30
  165.  
  166. c **verif produit scalaire entre v1 et v2*****
  167. 20 eps1=0.d0
  168. do i=1,3
  169. eps1=eps1+v33(i,1)*v33(i,2)
  170. end do
  171. c print*,'valp33 v1.v2=',eps1
  172. if(abs(eps1).gt.1.d-4) then
  173. c print*,'erreur produit scalaire v1 v2 av :',eps1
  174. c test produit scalaire v1 v3
  175. eps1=0.d0
  176. do i=1,3
  177. eps1=eps1+v33(i,1)*v33(i,3)
  178. end do
  179. if(abs(eps1).gt.1.d-4) then
  180. c print*,'erreur produit scalaire v1 v3 av :',eps1
  181. c correction de v1
  182. do i=1,3
  183. v33(i,1)=v33(i,1)-eps1*v33(i,3)
  184. end do
  185. c renormalisation
  186. xn=dsqrt(v33(1,1)**2+v33(2,1)**2+v33(3,1)**2)
  187. do i=1,3
  188. v33(i,1)=v33(i,1)/xn
  189. end do
  190. c erreur=.true.
  191. c goto 10
  192. end if
  193. c v1 et v3 etant orthogonaux on reconstruit v2 par produit
  194. c vectoriel
  195. v33(1,2)=v33(2,1)*v33(3,3)-v33(3,1)*v33(2,3)
  196. v33(2,2)=v33(3,1)*v33(1,3)-v33(1,1)*v33(3,3)
  197. v33(3,2)=v33(1,1)*v33(2,3)-v33(2,1)*v33(1,3)
  198. else
  199. c test produit scalaire v2 v3
  200. eps1=0.d0
  201. do i=1,3
  202. eps1=eps1+v33(i,2)*v33(i,3)
  203. end do
  204. c print*,'valp33 v2.v3=',eps1
  205. if(abs(eps1).gt.1.d-4) then
  206. c print*,'erreur produit scalaire v2 v3 av :',eps1
  207. c test produit scalaire v1 v3
  208. eps1=0.d0
  209. do i=1,3
  210. eps1=eps1+v33(i,1)*v33(i,3)
  211. end do
  212. if(abs(eps1).gt.1.d-4) then
  213. c print*,'erreur produit scalaire v1 v3 av :',eps1
  214. c correction de v3
  215. do i=1,3
  216. v33(i,3)=v33(i,3)-eps1*v33(i,1)
  217. end do
  218. c renormalisation
  219. xn=dsqrt(v33(1,3)**2+v33(2,3)**2+v33(3,3)**2)
  220. do i=1,3
  221. v33(i,3)=v33(i,3)/xn
  222. end do
  223. end if
  224. c v1 et v3 etant orthogonaux on reconstruit v2 par produit
  225. c vectoriel
  226. v33(1,2)=v33(2,1)*v33(3,3)-v33(3,1)*v33(2,3)
  227. v33(2,2)=v33(3,1)*v33(1,3)-v33(1,1)*v33(3,3)
  228. v33(3,2)=v33(1,1)*v33(2,3)-v33(2,1)*v33(1,3)
  229. else
  230. c test du produit scalaire entre v1 v3
  231. eps1=0.d0
  232. do i=1,3
  233. eps1=eps1+v33(i,1)*v33(i,3)
  234. end do
  235. c print*,'valp33 v3.v1=',eps1
  236. if(dabs(eps1).gt.1.d-4) then
  237. c print*,'erreur produit scalaire v3 v1 av :',eps1
  238. c test produit scalaire v3 v2
  239. eps1=0.d0
  240. do i=1,3
  241. eps1=eps1+v33(i,2)*v33(i,3)
  242. end do
  243. if(dabs(eps1).gt.1.d-4) then
  244. c print*,'erreur produit scalaire v3 v2 av :',eps1
  245. c correction de v3 avec v2
  246. do i=1,3
  247. v33(i,3)=v33(i,3)-eps1*v33(i,2)
  248. end do
  249. c renormalisation
  250. xn=dsqrt(v33(1,3)**2+v33(2,3)**2+v33(3,3)**2)
  251. do i=1,3
  252. v33(i,3)=v33(i,3)/xn
  253. end do
  254. c v2 et v3 etant orthogonaux on reconstruit v1 par produit
  255. c vectoriel
  256. v33(1,1)=v33(2,2)*v33(3,3)-v33(3,2)*v33(2,3)
  257. v33(2,1)=v33(3,2)*v33(1,3)-v33(1,2)*v33(3,3)
  258. v33(3,1)=v33(1,2)*v33(2,3)-v33(2,2)*v33(1,3)
  259. end if
  260. end if
  261. end if
  262. end if
  263.  
  264. 30 continue
  265. c mise en ordre du produit vectoriel
  266. v33(1,3)=v33(2,1)*v33(3,2)-v33(3,1)*v33(2,2)
  267. v33(2,3)=v33(3,1)*v33(1,2)-v33(1,1)*v33(3,2)
  268. v33(3,3)=v33(1,1)*v33(2,2)-v33(2,1)*v33(1,2)
  269.  
  270.  
  271. c matrice de passage inverse
  272. do i=1,3
  273. do j=1,3
  274. v33t(i,j)=v33(j,i)
  275. end do
  276. end do
  277.  
  278. c***********************************************
  279.  
  280. c verif validite des matrice de passage
  281. c (on change de nase une matrice unitaire)
  282.  
  283. call mtmt3d(v33,v33t,3,3,3,u33)
  284. c print*,'Image matrice identite apres correction'
  285. c call afic33(u33)
  286. do i=1,3
  287. do j=1,3
  288. if (i.eq.j)then
  289. if( abs(u33(i,i)-un) .gt. sqrt(epsv))then
  290. erreur=.true.
  291. goto 10
  292. endif
  293. else
  294. if( abs(u33(i,j)) .gt. sqrt(epsv))then
  295. erreur=.true.
  296. goto 10
  297. endif
  298. end if
  299. end do
  300. end do
  301. c affichage des variables en cas de pb de diagonalisation
  302. c10 continue
  303.  
  304.  
  305. 10 if(erreur)then
  306. print*,'_______________________________'
  307. print*,'pb vecteur propre ds b3_v33'
  308. print*,'matrice deja diagonale :',diago
  309. print*,'ordre :',ordre
  310. print*,'vp multiple :',vpmultiple
  311. print*,'matrice a diagonaliser :'
  312. call afic33(x33)
  313. print*,'valeurs propres:',x3(1),x3(2),x3(3)
  314. print*,'x1-x2',x3(1)-x3(2)
  315. print*,'x2-x3',x3(2)-x3(3)
  316. print*,'|',epsv,'*x(1)|',dabs(epsv * x3(1))
  317. print*,'|',epsv,'*x(2)|',dabs(epsv * x3(2))
  318. print*,'matrice de passage:'
  319. call afic33(v33)
  320. print*,'image matrice identite:'
  321. call afic33(u33)
  322. print*,'valeurs propres:',x3(1),x3(2),x3(3)
  323. print*,'matrice de passage:'
  324. call afic33(v33)
  325. c read*
  326. end if
  327.  
  328. return
  329. end
  330. ***************************************************************************************
  331.  
  332.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales