Allink  v0.1
Polymers.cpp
1 /***********************************************************************
2 Polymers: program that uses VarData's function for creating an initial
3 system of bonded monomers or for modifing a given system.
4 Every parameter of the VarData class are here set.
5 Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it>
6 
7 
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ***********************************************************************/
22 
23 #include "../include/VarData.h"
24 #define COMM_STRETCH 1
25 #define COMM_REMOVE 2
26 
27 int main(int argc,char **argv){
28  char nome1[120];
29  char nome2[120];
30  char ConfF[60];
31  sprintf(ConfF,"Polymers.conf");
32  VarData *Dat = new VarData();
33  int *FilePos = (int *)calloc(argc,sizeof(int));
34  int NFile = 0;
35  double StretchFact = 1.;
36  int Comando = 0;
37  double RefPos[3] = {.0,.0,.0};
38  sprintf(nome1,"ciccia.dat");
39  sprintf(nome2,"resume.dat");
40  for(int i=1;i<argc;i++){
41  if(argv[i][0] != '-'){
42  FilePos[NFile] = i;
43  NFile++;
44  }
45  else if(!strcmp(*(argv+i),"--Stretch")){
46  if(i<argc){
47  sscanf(*(argv+i+1),"%lf",&StretchFact);
48  i+=1;
49  Comando = COMM_STRETCH;
50  }
51  }
52  else if(!strcmp(*(argv+i),"--Rem")){
53  if(i<argc){
54  Comando = COMM_REMOVE;
55  }
56  }
57  else if(!strcmp(*(argv+i),"--Shift")){
58  if(i<argc-2){
59  for(int d=0;d<3;d++){
60  sscanf(*(argv+d+i+1),"%lf",RefPos+d);
61  }
62  i+=3;
63  }
64  }
65  else if(!strcmp(*(argv+i),"-c")){
66  if(i<argc){
67  sscanf(*(argv+i+1),"%s",ConfF);
68  i+=1;
69  }
70  }
71  }
72  if(NFile == 1)
73  sprintf(nome2,argv[FilePos[0]]);
74  if(NFile == 2){
75  sprintf(nome1,argv[FilePos[0]]);
76  sprintf(nome2,argv[FilePos[1]]);
77  }
78  printf("Apro %s e %s\n",nome1,nome2);
79  if(NFile == 2){
80  Dat->Open(nome1,BF_CHAIN);
81  char cSystem[STRSIZE];
82  Dat->SysInfo(cSystem);
83  if(Comando == COMM_STRETCH){
84  for(int d=0;d<2;d++)
85  Dat->Gen->Edge[d] = StretchFact*Dat->Gen->Edge[d];
86  for(int p=0;p<Dat->Gen->NPart;p++){
87  for(int d=0;d<3;d++)
88  Dat->Pm[p].Pos[d] = StretchFact*Dat->Pm[p].Pos[d];
89  Dat->Pm[p].Pos[2] = Dat->Pm[p].Pos[2] - 1.5;
90  }
91  for(int n=0;n<Dat->NNano;n++){
92  for(int d=0;d<2;d++)
93  Dat->Nano[n].Pos[d] *= StretchFact;
94  Dat->Nano[n].Rad *= StretchFact;
95  Dat->Nano[n].Height *= StretchFact;
96  }
97  }
98  if(Comando == COMM_REMOVE){
99  int NChain = Dat->Block[0].NChain;
100  }
101  Dat->Write(nome2);
102  }
103  else {
104  Dat->DefSoft(nome2,ConfF);
105  }
106  printf("Te se qe te ve be ne?\n");
107  return 0;
108 }
109 
BLOCK * Block
Information for every block.
Definition: VarData.h:1054
void SysInfo(char *cSystem)
Print a string with the system information.
Definition: VarData.cpp:164
NANO * Nano
Extra particle.
Definition: VarData.h:1044
bool Write(char *OutFile)
Writes a "system-file" or a "x y z" file".
double Edge[4]
xyzr edges of the simulation box
Definition: VarData.h:309
double Rad
Size.
Definition: VarData.h:445
double Height
Height of the cylinder.
Definition: VarData.h:449
double Pos[3]
xyz Position of the particle
Definition: VarData.h:216
bool Open(char *InFile, int BF)
Open the.
Definition: VarData.cpp:105
double Pos[3]
Position.
Definition: VarData.h:427
int NChain
chains
Definition: VarData.h:263
int DefSoft(char *nome2, char *ConfF)
Define and write the system as described in the conf file.
Reads and elaborates a system of chains.
Definition: VarData.h:521
PART * Pm
Particle information of all particle.
Definition: VarData.h:1046