Allink  v0.1
Polymers.cpp
00001 /***********************************************************************
00002 Polymers: program that uses VarData's function for creating an initial 
00003 system of bonded monomers or for modifing a given system. 
00004 Every parameter of the VarData class are here set.
00005 Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it>
00006 
00007 
00008 This program is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2 of the License, or
00011 (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 ***********************************************************************/
00022 
00023 #include "../include/VarData.h"
00024 #define COMM_STRETCH 1
00025 #define COMM_REMOVE 2
00026 
00027 int main(int argc,char **argv){
00028   char nome1[120];
00029   char nome2[120];
00030   char ConfF[60];
00031   sprintf(ConfF,"Polymers.conf");
00032   VarData *Dat = new VarData();
00033   int *FilePos = (int *)calloc(argc,sizeof(int));
00034   int NFile = 0;
00035   double StretchFact = 1.;
00036   int Comando = 0;
00037   double RefPos[3] = {.0,.0,.0};
00038   sprintf(nome1,"ciccia.dat");
00039   sprintf(nome2,"resume.dat");
00040   for(int i=1;i<argc;i++){
00041     if(argv[i][0] != '-'){
00042       FilePos[NFile] = i;
00043       NFile++;
00044     }
00045     else if(!strcmp(*(argv+i),"--Stretch")){
00046       if(i<argc){
00047    sscanf(*(argv+i+1),"%lf",&StretchFact);
00048    i+=1;
00049    Comando = COMM_STRETCH;
00050       }
00051     }
00052     else if(!strcmp(*(argv+i),"--Rem")){
00053       if(i<argc){
00054    Comando = COMM_REMOVE;
00055       }
00056     }
00057     else if(!strcmp(*(argv+i),"--Shift")){
00058       if(i<argc-2){
00059    for(int d=0;d<3;d++){
00060      sscanf(*(argv+d+i+1),"%lf",RefPos+d);
00061    }
00062    i+=3;
00063       }
00064     }
00065     else if(!strcmp(*(argv+i),"-c")){
00066       if(i<argc){
00067    sscanf(*(argv+i+1),"%s",ConfF);
00068    i+=1;
00069       }
00070     }    
00071   }
00072   if(NFile == 1)
00073     sprintf(nome2,argv[FilePos[0]]);
00074   if(NFile == 2){
00075     sprintf(nome1,argv[FilePos[0]]);    
00076     sprintf(nome2,argv[FilePos[1]]);
00077   }
00078   printf("Apro %s e %s\n",nome1,nome2);
00079   if(NFile == 2){
00080     Dat->Open(nome1,BF_CHAIN);
00081     char cSystem[STRSIZE];
00082     Dat->SysInfo(cSystem);
00083     if(Comando == COMM_STRETCH){
00084       for(int d=0;d<2;d++)
00085    Dat->Gen->Edge[d] = StretchFact*Dat->Gen->Edge[d];
00086       for(int p=0;p<Dat->Gen->NPart;p++){
00087    for(int d=0;d<3;d++)
00088      Dat->Pm[p].Pos[d] = StretchFact*Dat->Pm[p].Pos[d];
00089    Dat->Pm[p].Pos[2] = Dat->Pm[p].Pos[2] - 1.5;
00090       }
00091       for(int n=0;n<Dat->NNano;n++){
00092    for(int d=0;d<2;d++)
00093      Dat->Nano[n].Pos[d] *= StretchFact;
00094    Dat->Nano[n].Rad *= StretchFact;
00095    Dat->Nano[n].Height *= StretchFact;
00096       }
00097     }
00098     if(Comando == COMM_REMOVE){
00099       int NChain = Dat->Block[0].NChain;
00100     }
00101     Dat->Write(nome2);  
00102   }
00103   else {
00104     Dat->DefSoft(nome2,ConfF);
00105   }
00106   printf("Te se qe te ve be ne?\n");
00107   return 0;
00108 }
00109