Editing Source code for the minimum distance between two rods

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
The following is the FORTRAN source code for the calculation of the minimum distance between two rods in three dimensions. For full details see <ref>[http://dx.doi.org/10.1016/0097-8485(94)80023-5  Carlos Vega and Santiago Lago "A fast algorithm to evaluate the shortest distance between rods", Computers & Chemistry  '''18''' pp. 55-59 (1994)]</ref>. This code has also been [[Rev. source code for the minimum distance between two rods in C |implemented in C]].
{{Source}}
The following is the FORTRAN source code for the calculation of the minimum distance between two rods in three dimensions. For full details see Ref. 1.


  C  SUBROUTINE TO EVALUATE THE SHORTEST DISTANCE BETWEEN TWO RODS
  C  SUBROUTINE TO EVALUATE THE SHORTEST DISTANCE BETWEEN TWO RODS
Line 9: Line 10:
  C  XL2D2= HALF OF THE LENGTH OF ROD2
  C  XL2D2= HALF OF THE LENGTH OF ROD2
  C  RO2 = SQUARE OF THE SHORTEST DISTANCE BETWEEN THE TWO RODS
  C  RO2 = SQUARE OF THE SHORTEST DISTANCE BETWEEN THE TWO RODS
      SUBROUTINE SDM(R12,U1,U2,XL1D2,XL2D2,RO2)
      SUBROUTINE SDM(R12,U1,U2,XL1D2,XL2D2,RO2)
      DIMENSION R12(3),U1(3),U2(3)
      DIMENSION R12(3),U1(3),U2(3)
  C *****************
  C *****************
  C STEP 1
  C STEP 1
  C  SETTING TO ITS VALUE SOME VARIABLES
  C  SETTING TO ITS VALUE SOME VARIABLES
      R122=R12(1)**2+R12(2)**2+R12(3)**2
      R122=R12(1)**2+R12(2)**2+R12(3)**2
      R12EU1=R12(1)*U1(1)+R12(2)*U1(2)+R12(3)*U1(3)
      R12EU1=R12(1)*U1(1)+R12(2)*U1(2)+R12(3)*U1(3)
      R12EU2=R12(1)*U2(1)+R12(2)*U2(2)+R12(3)*U2(3)
      R12EU2=R12(1)*U2(1)+R12(2)*U2(2)+R12(3)*U2(3)
      U1EU2=U1(1)*U2(1)+U1(2)*U2(2)+U1(3)*U2(3)
      U1EU2=U1(1)*U2(1)+U1(2)*U2(2)+U1(3)*U2(3)
      CC=1.-U1EU2**2
      CC=1.-U1EU2**2
  C CHECKING WHETHER THE RODS ARE OR NOT PARALLEL
  C CHECKING WHETHER THE RODS ARE OR NOT PARALLEL
      IF (CC.LT.1.E-6) THEN
      IF (CC.LT.1.E-6) THEN
         IF (R12EU1.NE.0.) THEN
         IF (R12EU1.NE.0.) THEN
             XLANDA=SIGN(XL1D2,R12EU1)
             XLANDA=SIGN(XL1D2,R12EU1)
Line 29: Line 30:
             GO TO 20
             GO TO 20
         ENDIF
         ENDIF
      ENDIF
      ENDIF
  C  EVALUATION OF XLANDA PRIMA AND XMU PRIMA
  C  EVALUATION OF XLANDA PRIMA AND XMU PRIMA
      XLANDA=(R12EU1-U1EU2*R12EU2)/CC
      XLANDA=(R12EU1-U1EU2*R12EU2)/CC
      XMU=(-R12EU2+U1EU2*R12EU1)/CC
      XMU=(-R12EU2+U1EU2*R12EU1)/CC
  C END OF STEP 1  OF THE ALGORITHM
  C END OF STEP 1  OF THE ALGORITHM
  C ******************************
  C ******************************
Line 38: Line 39:
  C  CHECKING WHETHER (XLANDA PRIMA,XMUPRIMA) BELONGS  TO THE
  C  CHECKING WHETHER (XLANDA PRIMA,XMUPRIMA) BELONGS  TO THE
  C  RECTANGLE DEFINED BY THE TWO SEGMENTS IN THE XLANDA,XMU SPACE
  C  RECTANGLE DEFINED BY THE TWO SEGMENTS IN THE XLANDA,XMU SPACE
      IF ((ABS(XLANDA).LE.XL1D2).AND.(ABS(XMU).LE.XL2D2)) GO TO 20
      IF ((ABS(XLANDA).LE.XL1D2).AND.(ABS(XMU).LE.XL2D2)) GO TO 20
  C END OF STEP 2 OF THE ALGORITHM
  C END OF STEP 2 OF THE ALGORITHM
  C *********************************
  C *********************************
      AUXI1=ABS(XLANDA)-XL1D2
      AUXI1=ABS(XLANDA)-XL1D2
      AUXI2=ABS(XMU)-XL2D2
      AUXI2=ABS(XMU)-XL2D2
  C **********************
  C **********************
  C STEP 3
  C STEP 3
Line 81: Line 82:
  C SPACE WHERE STANDS THE SHORTEST DISTANCE BETWEEN THE SEGMENTS
  C SPACE WHERE STANDS THE SHORTEST DISTANCE BETWEEN THE SEGMENTS
  C EVALUATION OF THE SHORTEST DISTANCE
  C EVALUATION OF THE SHORTEST DISTANCE
  20    RO2=R122+XLANDA**2+XMU**2-2.*XLANDA*XMU*U1EU2
  20 RO2=R122+XLANDA**2+XMU**2-2.*XLANDA*XMU*U1EU2
      1    +2.*XMU*R12EU2-2.*XLANDA*R12EU1
    1    +2.*XMU*R12EU2-2.*XLANDA*R12EU1
  C END OF STEP 5
  C END OF STEP 5
  C **********************
  C **********************
      RETURN
      RETURN
      END
      END
 




==References==
==References==
<references/>
#[http://dx.doi.org/10.1016/0097-8485(94)80023-5  Carlos Vega and Santiago Lago "A fast algorithm to evaluate the shortest distance between rods", Computers & Chemistry  '''18''' pp. 55-59 (1994)]
 
{{Source}}
[[category: Fortran code]]
Please note that all contributions to SklogWiki are considered to be released under the Creative Commons Attribution Non-Commercial Share Alike (see SklogWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: