Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: digit-precision for gaussian inputs converting cartesian matrix from
Replies: 2   Last Post: Dec 5, 2012 3:10 AM

 Messages: [ Previous | Next ]
 locometro, INMETRO/UFRJ, Brasil - RJ Posts: 5 Registered: 11/11/12
digit-precision for gaussian inputs converting cartesian matrix from
Posted: Dec 3, 2012 3:33 AM

Hi Folks,

I have some issues to discuss here:

My goal: rotation,x-y plane, apllying over some cartesians vectors.

(*step 1:
I import a input.txt for Gaussian program like this: *)

%chk=campoX_1.chk
%mem=2gb
%nproc=4
#p b3lyp/6-31+g(d,p) geom=connectivity field=x+1 pop=reg int=ultrafine

single point campo direcao X+01

0 1
C 0.00000000 0.00000000 0.00000000
C 1.41786969 0.00000000 0.00000000
C -0.68401407 1.24221249 0.00000000
etc...(72lines).

(*step 2: I extract the data from input above, as below:*)

data2 = Take[data1, {9, 56}, {2, 4}]]
data3 = Flatten[Take[data1, {9, 56}, {1}]];
data4 = Drop[data1, {8, 56}, None];

(*As I need the 1st(molecules symbol), 2nd (X) , 3rd (Y) and 4th(Z) columns, for my table and calculations*).

(*step 3: Rotation 45 degree, over plane x-y, using the exctracted columns*)

rotZ = RotationMatrix[45 Degree, {0, 0, 1}];
datarotZ = (rotZ.#) & /@ data2 (*this promote the rotation matrice over x-y-x*)

output-> {{0., 0., 0.}, {1.00259, 1.00259, 0.}, {-1.36205, 0.394706,
0.}, {-2.49436, 0.668808, 0.00086376}, {1.85795,
1.79358, -0.00004936}, {-3.36958, -5.96549, -0.00908542}, \
{-2.95205, -7.30672, 0.00803008},...etc (* cartesians numbers already rotated 45 degrees*).

BUT NOTICE that the numbers of digits has been modified!, I need the original 8 digits, including zeros, after the decimal point! I do not want mathematica aplying any aproximation or cuts.

(*step 4: then I reduce the data back to a table form:*)

datafinal = Partition[Flatten[Transpose[{data3, datarotZ}], 2], 4] ;
FlattenAt[Insert[data4, datafinal, 9], 9]
(*I use this because, in the middle of the output list appears doubles "{{" "}}", any suggestion?*);

(*step5: final table:*) ( just want to put things as the same original input table which data were extracted*)

tabelafinal =
Grid[datafinal, ItemSize -> {{1, 18, 7, 7}, 1}, Alignment -> "."]

output -> {
{"C", 0., 0., 0.},
{"C", 1.00259, 1.00259, 0.},
{"C", -1.36205, 0.394706, 0.},
{"N", -2.49436, 0.668808, 0.00086376},
{"N", 1.85795, 1.79358, -0.00004936},
{"C", -3.36958, -5.96549, -0.00908542}
}

And finally when I export tabela final:

Export["RotZinput.txt", %, "table"]

(* the final table in txt file is not so well formatted. See what happens to "0.", it takes the decimals zeros, why?

and some numbers do not have the same digits. I just need 8 digits after "." and columns aligned to ".", as the original input.*)

%chk=campoX_1.chk
%mem=2gb
%nproc=4
#p b3lyp/6-31+g(d,p) geom=connectivity field=x+1 pop=reg int=ultrafine

single point campo direcao X+01

C 0. 0. 0.
C 1.002585272637868 1.002585272637868 0.
C -1.362047862677636 0.39470588802961654 0.
N -2.4943601616156514 0.6688078909474289 0.00086376
N 1.8579481345030466 1.7935803739172627 -0.00004936
C -3.369578072779666 -5.965493596202908 -0.00908542....etc.