function y=resgenerator_1(a,b,c,alpha,beta,gamma,atomtypes,x,y,z,occupancy,resfilename) %%%This function takes as inputs the unit cell parameters, the atom types %%%present (SFAC), the numbers of each atom present (UNIT), the atom list %%%(atomtypes) as a row vector, the number corresponding to each atom type %%%(atomnumbers) as a row vector, and the fractional coordinates x, y, and %%%z as row vectors. It outputs a dummy res file that can be used to %%%visualize the packing. alpha=alpha*180/pi;beta=beta*180/pi;gamma=gamma*180/pi; %Merge atoms that end up on the same site x=mod(x,1);y=mod(y,1);z=mod(z,1); n=1; while(n<=length(x)) m=n+1; while(m<=length(x)) if x(n)==x(m) && y(n)==y(m) && z(n)==z(m) x(m)=[];y(m)=[];z(m)=[];atomtypes(m)=[];occupancy(n)=occupancy(n)+occupancy(m);occupancy(m)=[]; else m=m+1; end end n=n+1; end occupancy=occupancy+10; n=1; SFAC=atomtypes(1); while(n<=length(atomtypes)) current=char(atomtypes(n)); if sum(ismember(SFAC,current))>0 n=n+1; else SFAC(length(SFAC)+1)={current}; n=n+1; end end n=1; atomnumbers=[]; UNIT=zeros(1,length(SFAC)); while(n<=length(atomtypes)) current=char(atomtypes(n)); atomnumbers(length(atomnumbers)+1)=find(ismember(SFAC,current),1); UNIT(find(ismember(SFAC,current),1))=UNIT(find(ismember(SFAC,current),1))+1; n=n+1; end fid=fopen(resfilename,'w'); fprintf(fid,'TITL MATLAB structure\nCELL 0.71073 %3.4f %3.4f %3.4f %3.3f %3.3f %3.3f\nZERR 1 0 0 0 0 0 0\nLATT -1\n',a,b,c,alpha,beta,gamma); n=1; fprintf(fid,'SFAC '); while(n<=length(SFAC)) fprintf(fid,'%s ',char(SFAC(n))); n=n+1; end fprintf(fid,'\n'); fprintf(fid,'UNIT '); n=1; while(n<=length(UNIT)) fprintf(fid,'%d ',UNIT(n)); n=n+1; end fprintf(fid,'\n'); fprintf(fid,'L.S. 10\nBOND $H\nFMAP 2\nPLAN 10\nWGHT 0.1\nFVAR 0.1 \n'); n=1; while(n<=length(atomtypes)) fprintf(fid,'%s %d %1.5f %1.5f %1.5f %1.5f 0.05\n',char(atomtypes(n)),atomnumbers(n),x(n),y(n),z(n),occupancy(n)); n=n+1; end fprintf(fid,'HKLF 4\n\nEND'); y=5;