Skip to content

Commit

Permalink
Move writeTPL to be a method for Gaussian
Browse files Browse the repository at this point in the history
  • Loading branch information
crcollins committed Jun 26, 2013
1 parent ec5ed1c commit f23933c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
41 changes: 4 additions & 37 deletions @Decompose/initialize.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ function initialize(obj)
% Calculation on the full molecule
fullList = [obj.fragList{1}(:);obj.fragList{2}(:)];
keywords = ['td ', obj.keywords];
tempdir = writeTPL(obj,obj.fullIn.filename,fullList,keywords);
name = obj.fullIn.filename;
tempdir = obj.fullIn.writeTPL(name,fullList,keywords);
obj.full = Gaussian(tempdir,obj.fullIn.filename,struct);
obj.full.run();

Expand All @@ -19,7 +20,7 @@ function initialize(obj)
obj.rlinks(2) * direction/norm(direction);
for ifrag = 1:2
name = [obj.fullIn.filename,'-',int2str(ifrag)];
tempdir = writeTPL(obj,name,obj.fragList{ifrag},obj.keywords,rLink{ifrag});
tempdir = obj.full.writeTPL(name,obj.fragList{ifrag},obj.keywords,rLink{ifrag});
obj.frags{ifrag} = Gaussian(tempdir,name,struct);
obj.frags{ifrag}.run();
end
Expand All @@ -44,38 +45,4 @@ function initialize(obj)
ofull = obj.full.orb(:,:);
obj.overlap{ifrag} = ofrag' * Stemp * ofull;
end
end


function tempDir = writeTPL(obj,jobname,atoms,keywords,rLink)
newline = char(10);
syms{1} = 'H'; syms{6} = 'C'; syms{7} = 'N'; syms{8} = 'O';
syms{15} = 'P'; syms{16} = 'S';
tpl_file = [jobname,'.tpl'];
tempDir = [tempname('C:\G09W\Scratch'), '\'];
mkdir(tempDir);
fid1 = fopen([tempDir,tpl_file],'w');

fwrite(fid1,['%chk=temp.chk',newline]);
fwrite(fid1,['# ',keywords,' NoSymmetry iop(3/33=4) pop=regular',newline]);
fwrite(fid1,newline);
fwrite(fid1,jobname);
fwrite(fid1,newline);
fwrite(fid1,newline);
fwrite(fid1,'0 1');
fwrite(fid1,newline);
for iatom = atoms(:)'
fwrite(fid1,[' ',syms{obj.fullIn.Z(iatom)},' ']);
for ic = 1:3
fwrite(fid1,[num2str(obj.fullIn.rcart(ic,iatom)),' ']);
end
fwrite(fid1,newline);
end
if (nargin > 4)
fwrite(fid1,[' H ',num2str(rLink(:)'),newline]);
end
fwrite(fid1,newline);

fclose(fid1);
end

end
35 changes: 35 additions & 0 deletions @Gaussian/writeTPL.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function tempDir = writeTPL(obj,jobname,atoms,keywords,rLink)
if isempty(atoms)
atoms = 1:length(obj.Z);
end
newline = char(10);
syms{1} = 'H'; syms{6} = 'C'; syms{7} = 'N'; syms{8} = 'O';
syms{15} = 'P'; syms{16} = 'S';
tpl_file = [jobname,'.tpl'];
tempDir = [tempname('C:\G09W\Scratch'), '\'];
mkdir(tempDir);
fid1 = fopen([tempDir,tpl_file],'w');

fwrite(fid1,['%chk=temp.chk',newline]);
fwrite(fid1,['# ',keywords,' NoSymmetry iop(3/33=4) pop=regular',newline]);
fwrite(fid1,newline);
fwrite(fid1,jobname);
fwrite(fid1,newline);
fwrite(fid1,newline);
fwrite(fid1,sprintf('%d %d', obj.charge, obj.multiplicity));
fwrite(fid1,newline);
for iatom = atoms(:)'
fwrite(fid1,[' ',syms{obj.Z(iatom)},' ']);
for ic = 1:3
fwrite(fid1,[num2str(obj.rcart(ic,iatom)),' ']);
end
fwrite(fid1,newline);
end
if (nargin > 4)
fwrite(fid1,[' H ',num2str(rLink(:)'),newline]);
end
fwrite(fid1,newline);

fclose(fid1);
end

0 comments on commit f23933c

Please sign in to comment.