|
| 1 | +{Name -> "DihedralEnergy", AdditionalCDeclares -> "", |
| 2 | + Input -> {x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, V, DN, IN, |
| 3 | + cosPhase, sinPhase}, Output -> {Energy, DihedralDeviation}, |
| 4 | + EnergyFunction -> "NotUsed", DerivativeVariables -> |
| 5 | + {x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4}, |
| 6 | + Rules -> {CCode["DIHEDRAL_SET_PARAMETER(sinPhase);"], |
| 7 | + CCode["DIHEDRAL_SET_PARAMETER(cosPhase);"], |
| 8 | + CCode["DIHEDRAL_SET_PARAMETER(V);"], CCode["DIHEDRAL_SET_PARAMETER(DN);"], |
| 9 | + CCode["DIHEDRAL_SET_PARAMETER(IN);"], |
| 10 | + CCode["DIHEDRAL_SET_PARAMETER(I1);"], |
| 11 | + CCode["DIHEDRAL_SET_PARAMETER(I2);"], |
| 12 | + CCode["DIHEDRAL_SET_PARAMETER(I3);"], |
| 13 | + CCode["DIHEDRAL_SET_PARAMETER(I4);"], |
| 14 | + CCode["DIHEDRAL_SET_POSITION(x1,I1,0);"], |
| 15 | + CCode["DIHEDRAL_SET_POSITION(y1,I1,1);"], |
| 16 | + CCode["DIHEDRAL_SET_POSITION(z1,I1,2);"], |
| 17 | + CCode["DIHEDRAL_SET_POSITION(x2,I2,0);"], |
| 18 | + CCode["DIHEDRAL_SET_POSITION(y2,I2,1);"], |
| 19 | + CCode["DIHEDRAL_SET_POSITION(z2,I2,2);"], |
| 20 | + CCode["DIHEDRAL_SET_POSITION(x3,I3,0);"], |
| 21 | + CCode["DIHEDRAL_SET_POSITION(y3,I3,1);"], |
| 22 | + CCode["DIHEDRAL_SET_POSITION(z3,I3,2);"], |
| 23 | + CCode["DIHEDRAL_SET_POSITION(x4,I4,0);"], |
| 24 | + CCode["DIHEDRAL_SET_POSITION(y4,I4,1);"], |
| 25 | + CCode["DIHEDRAL_SET_POSITION(z4,I4,2);"], -(x2*y1) -> tx69, x3*y1 -> tx70, |
| 26 | + x1*y2 -> tx71, -(x3*y2) -> tx72, -(x1*y3) -> tx73, x2*y3 -> tx74, |
| 27 | + x2*z1 -> tx75, -(x3*z1) -> tx76, -(y2*z1) -> tx77, y3*z1 -> tx78, |
| 28 | + -(x1*z2) -> tx79, x3*z2 -> tx80, y1*z2 -> tx81, -(y3*z2) -> tx82, |
| 29 | + x1*z3 -> tx83, -(x2*z3) -> tx84, -(y1*z3) -> tx85, y2*z3 -> tx86, |
| 30 | + tx69 + tx70 + tx71 + tx72 + tx73 + tx74 -> tx87, |
| 31 | + tx75 + tx76 + tx79 + tx80 + tx83 + tx84 -> tx88, |
| 32 | + tx77 + tx78 + tx81 + tx82 + tx85 + tx86 -> tx89, power2[tx87] -> tx90, |
| 33 | + power2[tx88] -> tx91, power2[tx89] -> tx92, tx90 + tx91 + tx92 -> tx93, |
| 34 | + mysqrt[tx93] -> LenA, x4*y2 -> tx94, -(x4*y3) -> tx95, -(x2*y4) -> tx96, |
| 35 | + x3*y4 -> tx97, -(x4*z2) -> tx98, y4*z2 -> tx99, x4*z3 -> tx100, |
| 36 | + -(y4*z3) -> tx101, x2*z4 -> tx102, -(x3*z4) -> tx103, -(y2*z4) -> tx104, |
| 37 | + y3*z4 -> tx105, tx72 + tx74 + tx94 + tx95 + tx96 + tx97 -> tx106, |
| 38 | + tx100 + tx102 + tx103 + tx80 + tx84 + tx98 -> tx107, |
| 39 | + tx101 + tx104 + tx105 + tx82 + tx86 + tx99 -> tx108, |
| 40 | + power2[tx106] -> tx109, power2[tx107] -> tx110, power2[tx108] -> tx111, |
| 41 | + tx109 + tx110 + tx111 -> tx112, mysqrt[tx112] -> LenB, |
| 42 | + reciprocal[LenA] -> ReciprocalLenA, reciprocal[LenB] -> ReciprocalLenB, |
| 43 | + CCode["if (fabs(LenA)<TENM3) ReciprocalLenA = 0.0;"], |
| 44 | + CCode["if (fabs(LenB)<TENM3) ReciprocalLenB = 0.0;"], |
| 45 | + ReciprocalLenA*ReciprocalLenB -> RecLenARecLenB, |
| 46 | + CCode["EraseLinearDihedral = 1.0;"], |
| 47 | + CCode["if (RecLenARecLenB==0.0) EraseLinearDihedral = 0.0;"], |
| 48 | + tx106*tx87 -> tx113, tx107*tx88 -> tx114, tx108*tx89 -> tx115, |
| 49 | + tx113 + tx114 + tx115 -> tx116, RecLenARecLenB*tx116 -> CosPhi, |
| 50 | + -x3 -> tx117, -y3 -> tx118, -z3 -> tx119, tx117 + x2 -> tx120, |
| 51 | + tx118 + y2 -> tx121, tx119 + z2 -> tx122, power2[tx120] -> tx123, |
| 52 | + power2[tx121] -> tx124, power2[tx122] -> tx125, tx117 + x4 -> tx126, |
| 53 | + tx118 + y4 -> tx127, tx119 + z4 -> tx128, tx123 + tx124 + tx125 -> tx129, |
| 54 | + tx128*tx87 -> tx130, tx127*tx88 -> tx131, tx126*tx89 -> tx132, |
| 55 | + mysqrt[tx129] -> tx133, tx130 + tx131 + tx132 -> tx134, |
| 56 | + RecLenARecLenB*tx133*tx134 -> SinPhi, |
| 57 | + CCode["CosPhi=MAX(-1.0,MIN(1.0,CosPhi));"], |
| 58 | + MathCode["CosNPhi = mathCosNPhi[IN,SinPhi,CosPhi];"], |
| 59 | + MathCode["SinNPhi = mathSinNPhi[IN,SinPhi,CosPhi];"], |
| 60 | + CCode["sinNPhiCosNPhi(IN, &SinNPhi, &CosNPhi, SinPhi, CosPhi);"], |
| 61 | + CosNPhi*cosPhase -> tx135, SinNPhi*sinPhase -> tx136, |
| 62 | + 1. + tx135 + tx136 -> DihedralDeviation, |
| 63 | + DihedralDeviation*EraseLinearDihedral*V -> Energy, |
| 64 | + CCode["DIHEDRAL_ENERGY_ACCUMULATE(Energy);"]}, |
| 65 | + HessianStructure -> {{14, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}, |
| 66 | + {26, 15, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}, |
| 67 | + {27, 37, 16, 47, 48, 49, 50, 51, 52, 53, 54, 55}, |
| 68 | + {28, 38, 47, 17, 56, 57, 58, 59, 60, 61, 62, 63}, |
| 69 | + {29, 39, 48, 56, 18, 64, 65, 66, 67, 68, 69, 70}, |
| 70 | + {30, 40, 49, 57, 64, 19, 71, 72, 73, 74, 75, 76}, |
| 71 | + {31, 41, 50, 58, 65, 71, 20, 77, 78, 79, 80, 81}, |
| 72 | + {32, 42, 51, 59, 66, 72, 77, 21, 82, 83, 84, 85}, |
| 73 | + {33, 43, 52, 60, 67, 73, 78, 82, 22, 86, 87, 88}, |
| 74 | + {34, 44, 53, 61, 68, 74, 79, 83, 86, 23, 89, 90}, |
| 75 | + {35, 45, 54, 62, 69, 75, 80, 84, 87, 89, 24, 91}, |
| 76 | + {36, 46, 55, 63, 70, 76, 81, 85, 88, 90, 91, 25}}, CCode -> "NOT USED", |
| 77 | + MathCode -> "Block[{CosPhi,DihedralDeviation,Energy,LenA,LenB,ReciprocalLenA\ |
| 78 | +,ReciprocalLenB,RecLenARecLenB,SinPhi,tx100,tx101,tx102,tx103,tx104,tx105,tx1\ |
| 79 | +06,tx107,tx108,tx109,tx110,tx111,tx112,tx113,tx114,tx115,tx116,tx117,tx118,tx\ |
| 80 | +119,tx120,tx121,tx122,tx123,tx124,tx125,tx126,tx127,tx128,tx129,tx130,tx131,t\ |
| 81 | +x132,tx133,tx134,tx135,tx136,tx69,tx70,tx71,tx72,tx73,tx74,tx75,tx76,tx77,tx7\ |
| 82 | +8,tx79,tx80,tx81,tx82,tx83,tx84,tx85,tx86,tx87,tx88,tx89,tx90,tx91,tx92,tx93,\ |
| 83 | +tx94,tx95,tx96,tx97,tx98,tx99,xxxDummy},\n\t(*DIHEDRAL_SET_PARAMETER(sinPhase\ |
| 84 | +);*)\n\t(*DIHEDRAL_SET_PARAMETER(cosPhase);*)\n\t(*DIHEDRAL_SET_PARAMETER(V);\ |
| 85 | +*)\n\t(*DIHEDRAL_SET_PARAMETER(DN);*)\n\t(*DIHEDRAL_SET_PARAMETER(IN);*)\n\t(\ |
| 86 | +*DIHEDRAL_SET_PARAMETER(I1);*)\n\t(*DIHEDRAL_SET_PARAMETER(I2);*)\n\t(*DIHEDR\ |
| 87 | +AL_SET_PARAMETER(I3);*)\n\t(*DIHEDRAL_SET_PARAMETER(I4);*)\n\t(*DIHEDRAL_SET_\ |
| 88 | +POSITION(x1,I1,0);*)\n\t(*DIHEDRAL_SET_POSITION(y1,I1,1);*)\n\t(*DIHEDRAL_SET\ |
| 89 | +_POSITION(z1,I1,2);*)\n\t(*DIHEDRAL_SET_POSITION(x2,I2,0);*)\n\t(*DIHEDRAL_SE\ |
| 90 | +T_POSITION(y2,I2,1);*)\n\t(*DIHEDRAL_SET_POSITION(z2,I2,2);*)\n\t(*DIHEDRAL_S\ |
| 91 | +ET_POSITION(x3,I3,0);*)\n\t(*DIHEDRAL_SET_POSITION(y3,I3,1);*)\n\t(*DIHEDRAL_\ |
| 92 | +SET_POSITION(z3,I3,2);*)\n\t(*DIHEDRAL_SET_POSITION(x4,I4,0);*)\n\t(*DIHEDRAL\ |
| 93 | +_SET_POSITION(y4,I4,1);*)\n\t(*DIHEDRAL_SET_POSITION(z4,I4,2);*)\n\ttx69=-(x2 \ |
| 94 | +y1); (*Rule 22*)\n\ttx70=x3 y1; (*Rule 23*)\n\ttx71=x1 y2; (*Rule \ |
| 95 | +24*)\n\ttx72=-(x3 y2); (*Rule 25*)\n\ttx73=-(x1 y3); (*Rule 26*)\n\ttx74=x2 \ |
| 96 | +y3; (*Rule 27*)\n\ttx75=x2 z1; (*Rule 28*)\n\ttx76=-(x3 z1); (*Rule \ |
| 97 | +29*)\n\ttx77=-(y2 z1); (*Rule 30*)\n\ttx78=y3 z1; (*Rule 31*)\n\ttx79=-(x1 \ |
| 98 | +z2); (*Rule 32*)\n\ttx80=x3 z2; (*Rule 33*)\n\ttx81=y1 z2; (*Rule \ |
| 99 | +34*)\n\ttx82=-(y3 z2); (*Rule 35*)\n\ttx83=x1 z3; (*Rule 36*)\n\ttx84=-(x2 \ |
| 100 | +z3); (*Rule 37*)\n\ttx85=-(y1 z3); (*Rule 38*)\n\ttx86=y2 z3; (*Rule \ |
| 101 | +39*)\n\ttx87=tx69 + tx70 + tx71 + tx72 + tx73 + tx74; (*Rule \ |
| 102 | +40*)\n\ttx88=tx75 + tx76 + tx79 + tx80 + tx83 + tx84; (*Rule \ |
| 103 | +41*)\n\ttx89=tx77 + tx78 + tx81 + tx82 + tx85 + tx86; (*Rule 42*)\n\ttx90= \ |
| 104 | +mathPower2[tx87]; (*Rule 43*)\n\ttx91= mathPower2[tx88]; (*Rule 44*)\n\ttx92= \ |
| 105 | +mathPower2[tx89]; (*Rule 45*)\n\ttx93=tx90 + tx91 + tx92; (*Rule \ |
| 106 | +46*)\n\tLenA= mathSqrt[tx93]; (*Rule 47*)\n\ttx94=x4 y2; (*Rule \ |
| 107 | +48*)\n\ttx95=-(x4 y3); (*Rule 49*)\n\ttx96=-(x2 y4); (*Rule 50*)\n\ttx97=x3 \ |
| 108 | +y4; (*Rule 51*)\n\ttx98=-(x4 z2); (*Rule 52*)\n\ttx99=y4 z2; (*Rule \ |
| 109 | +53*)\n\ttx100=x4 z3; (*Rule 54*)\n\ttx101=-(y4 z3); (*Rule 55*)\n\ttx102=x2 \ |
| 110 | +z4; (*Rule 56*)\n\ttx103=-(x3 z4); (*Rule 57*)\n\ttx104=-(y2 z4); (*Rule \ |
| 111 | +58*)\n\ttx105=y3 z4; (*Rule 59*)\n\ttx106=tx72 + tx74 + tx94 + tx95 + tx96 + \ |
| 112 | +tx97; (*Rule 60*)\n\ttx107=tx100 + tx102 + tx103 + tx80 + tx84 + tx98; (*Rule \ |
| 113 | +61*)\n\ttx108=tx101 + tx104 + tx105 + tx82 + tx86 + tx99; (*Rule \ |
| 114 | +62*)\n\ttx109= mathPower2[tx106]; (*Rule 63*)\n\ttx110= mathPower2[tx107]; \ |
| 115 | +(*Rule 64*)\n\ttx111= mathPower2[tx108]; (*Rule 65*)\n\ttx112=tx109 + tx110 + \ |
| 116 | +tx111; (*Rule 66*)\n\tLenB= mathSqrt[tx112]; (*Rule 67*)\n\tReciprocalLenA= \ |
| 117 | +mathReciprocal[LenA]; (*Rule 68*)\n\tReciprocalLenB= mathReciprocal[LenB]; \ |
| 118 | +(*Rule 69*)\n\t(*if (fabs(LenA)<TENM3) ReciprocalLenA = 0.0;*)\n\t(*if \ |
| 119 | +(fabs(LenB)<TENM3) ReciprocalLenB = 0.0;*)\n\tRecLenARecLenB=ReciprocalLenA \ |
| 120 | +ReciprocalLenB; (*Rule 72*)\n\t(*EraseLinearDihedral = 1.0;*)\n\t(*if \ |
| 121 | +(RecLenARecLenB==0.0) EraseLinearDihedral = 0.0;*)\n\ttx113=tx106 tx87; \ |
| 122 | +(*Rule 75*)\n\ttx114=tx107 tx88; (*Rule 76*)\n\ttx115=tx108 tx89; (*Rule \ |
| 123 | +77*)\n\ttx116=tx113 + tx114 + tx115; (*Rule 78*)\n\tCosPhi=RecLenARecLenB \ |
| 124 | +tx116; (*Rule 79*)\n\ttx117=-x3; (*Rule 80*)\n\ttx118=-y3; (*Rule \ |
| 125 | +81*)\n\ttx119=-z3; (*Rule 82*)\n\ttx120=tx117 + x2; (*Rule \ |
| 126 | +83*)\n\ttx121=tx118 + y2; (*Rule 84*)\n\ttx122=tx119 + z2; (*Rule \ |
| 127 | +85*)\n\ttx123= mathPower2[tx120]; (*Rule 86*)\n\ttx124= mathPower2[tx121]; \ |
| 128 | +(*Rule 87*)\n\ttx125= mathPower2[tx122]; (*Rule 88*)\n\ttx126=tx117 + x4; \ |
| 129 | +(*Rule 89*)\n\ttx127=tx118 + y4; (*Rule 90*)\n\ttx128=tx119 + z4; (*Rule \ |
| 130 | +91*)\n\ttx129=tx123 + tx124 + tx125; (*Rule 92*)\n\ttx130=tx128 tx87; (*Rule \ |
| 131 | +93*)\n\ttx131=tx127 tx88; (*Rule 94*)\n\ttx132=tx126 tx89; (*Rule \ |
| 132 | +95*)\n\ttx133= mathSqrt[tx129]; (*Rule 96*)\n\ttx134=tx130 + tx131 + tx132; \ |
| 133 | +(*Rule 97*)\n\tSinPhi=RecLenARecLenB tx133 tx134; (*Rule \ |
| 134 | +98*)\n\t(*CosPhi=MAX(-1.0,MIN(1.0,CosPhi));*)\n\tCosNPhi = \ |
| 135 | +mathCosNPhi[IN,SinPhi,CosPhi];\n\tSinNPhi = \ |
| 136 | +mathSinNPhi[IN,SinPhi,CosPhi];\n\t(*sinNPhiCosNPhi(IN, &SinNPhi, &CosNPhi, \ |
| 137 | +SinPhi, CosPhi);*)\n\ttx135=CosNPhi cosPhase; (*Rule 103*)\n\ttx136=SinNPhi \ |
| 138 | +sinPhase; (*Rule 104*)\n\tDihedralDeviation=1. + tx135 + tx136; (*Rule \ |
| 139 | +105*)\n\tEnergy=DihedralDeviation EraseLinearDihedral V; (*Rule \ |
| 140 | +106*)\n\t(*DIHEDRAL_ENERGY_ACCUMULATE(Energy);*)\n{Energy, \ |
| 141 | +DihedralDeviation}]\n"} |
0 commit comments