- Timestamp:
- Apr 21, 2008, 2:19:23 PM (17 years ago)
- Children:
- 27a5bf
- Parents:
- 963310a
- git-author:
- Frederik Heber <heber@…> (04/18/08 14:05:08)
- git-committer:
- Frederik Heber <heber@…> (04/21/08 14:19:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pcp/src/run.c
r963310a r2026d4 1153 1153 SpeedMeasure(P, SimTime, StopTimeDo); 1154 1154 ControlNativeDensity(P); 1155 TestGramSch(P,LevS,Psi, Occupied); 1156 1157 1158 1159 1160 1161 1162 1163 1164 1155 TestGramSch(P,LevS,Psi, Occupied); 1156 // necessary for correct ionic forces ... 1157 SpeedMeasure(P, LocFTime, StartTimeDo); 1158 CalculateIonLocalForce(P); 1159 SpeedMeasure(P, LocFTime, StopTimeDo); 1160 SpeedMeasure(P, NonLocFTime, StartTimeDo); 1161 CalculateIonNonLocalForce(P); 1162 SpeedMeasure(P, NonLocFTime, StopTimeDo); 1163 CalculateEwald(P, 1); 1164 CalculateIonForce(P); 1165 1165 } 1166 1166 if (P->Call.ForcesFile != NULL) { // if we parse forces from file, values are written over (in case of DoOutVis) … … 1168 1168 //ParseIonForce(P); 1169 1169 //CalculateIonForce(P); 1170 } 1170 } 1171 1171 CorrectForces(P); 1172 1172 // ... on output of densities … … 1177 1177 1178 1178 //OutputNorm(P); 1179 //fprintf(stderr,"(%i) DoubleG: %p, CArray[22]: %p, OldLocalPsi: %p\n", P->Par.me, R->LevS->DoubleG, R->Lev0->Dens->DensityCArray[22], R->LevS->LPsi->OldLocalPsi); 1179 //fprintf(stderr,"(%i) DoubleG: %p, CArray[22]: %p, OldLocalPsi: %p\n", P->Par.me, R->LevS->DoubleG, R->Lev0->Dens->DensityCArray[22], R->LevS->LPsi->OldLocalPsi); 1180 1180 //OutputVis(P, P->R.Lev0->Dens->DensityArray[TotalDensity]); 1181 /*TestGramSch(P, LevS,Psi, &P->Lat.Psi); */1181 /*TestGramSch(P, R->LevS, &P->Lat.Psi); */ 1182 1182 GetOuterStop(P); 1183 1183 //fprintf(stderr,"(%i) DoubleG: %p, CArray[22]: %p, OldLocalPsi: %p\n", P->Par.me, R->LevS->DoubleG, R->Lev0->Dens->DensityCArray[22], R->LevS->LPsi->OldLocalPsi); 1184 1184 if (SuperStop) OuterStop = 1; 1185 1185 return OuterStop; 1186 } 1187 1188 /** Checks whether the given positions \a *v have changed wrt stored in IonData structure. 1189 * \param *P Problem at hand 1190 * \param *v gsl_vector storing new positions 1191 */ 1192 int CheckForChangedPositions(struct Problem *P, const gsl_vector *v) 1193 { 1194 struct Ions *I = &P->Ion; 1195 int is,ia,k, index=0; 1196 int diff = 0; 1197 double *R_ion; 1198 for (is=0; is < I->Max_Types; is++) // for all elements 1199 for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) { // for all ions of element 1200 R_ion = &I->I[is].R[NDIM*ia]; 1201 for (k=0;k<NDIM;k++) { // for all dimensions 1202 if (fabs(R_ion[k] - gsl_vector_get (v, index++)) > MYEPSILON) 1203 diff++; 1204 } 1205 } 1206 return diff; 1207 } 1208 1209 /** Wrapper for CalculateForce() for simplex minimisation of total energy. 1210 * \param *v vector with degrees of freedom 1211 * \param *params additional arguments, here Problem at hand 1212 */ 1213 double StructOpt_func(const gsl_vector *v, void *params) 1214 { 1215 struct Problem *P = (struct Problem *)params; 1216 struct RunStruct *R = &P->R; 1217 struct Ions *I = &P->Ion; 1218 struct Energy *E = P->Lat.E; 1219 int i; 1220 double *R_ion, *R_old, *R_old_old;//, *FIon; 1221 //double norm = 0.; 1222 int is,ia,k,index = 0; 1223 int OuterStop; 1224 double diff = 0., tmp; 1225 debug (P, "StructOpt_func"); 1226 if (CheckForChangedPositions(P,v)) { 1227 // update ion positions from vector coordinates 1228 for (is=0; is < I->Max_Types; is++) // for all elements 1229 for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) { // for all ions of element 1230 R_ion = &I->I[is].R[NDIM*ia]; 1231 R_old = &I->I[is].R_old[NDIM*ia]; 1232 R_old_old = &I->I[is].R_old_old[NDIM*ia]; 1233 tmp = 0.; 1234 for (k=0;k<NDIM;k++) { // for all dimensions 1235 R_old_old[k] = R_old[k]; 1236 R_old[k] = R_ion[k]; 1237 tmp += (R_ion[k]-gsl_vector_get (v, index))*(R_ion[k]-gsl_vector_get (v, index)); 1238 R_ion[k] = gsl_vector_get (v, index++); 1239 } 1240 diff += sqrt(tmp); 1241 } 1242 if (P->Call.out[ValueOut]) fprintf(stderr,"(%i) Summed Difference to former position %lg\n", P->Par.me, diff); 1243 // recalculate ionic forces (do electronic minimisation) 1244 R->OuterStep++; 1245 R->NewRStep++; 1246 UpdateWaveAfterIonMove(P); 1247 for (i=MAXOLD-1; i > 0; i--) // store away old energies 1248 E->TotalEnergyOuter[i] = E->TotalEnergyOuter[i-1]; 1249 UpdateToNewWaves(P); 1250 E->TotalEnergyOuter[0] = E->TotalEnergy[0]; 1251 OuterStop = CalculateForce(P); 1252 //UpdateIonsU(P); 1253 //CorrectVelocity(P); 1254 //CalculateEnergyIonsU(P); 1255 /* if ((P->R.ScaleTempStep > 0) && ((R->OuterStep-1) % P->R.ScaleTempStep == 0)) 1256 ScaleTemp(P);*/ 1257 if ((R->OuterStep-1) % P->R.OutSrcStep == 0) 1258 OutputVisSrcFiles(P, Occupied); 1259 if ((R->OuterStep-1) % P->R.OutVisStep == 0) { 1260 /* // recalculate density for the specific wave function ... 1261 CalculateOneDensityR(Lat, LevS, Dens0, PsiDat, Dens0->DensityArray[ActualDensity], R->FactorDensityR, 0); 1262 // ... and output (wherein ActualDensity is used instead of TotalDensity) 1263 OutputVis(P); 1264 OutputIonForce(P); 1265 EnergyOutput(P, 1);*/ 1266 } 1267 } 1268 if (P->Par.me == 0) fprintf(stderr,"(%i) TE %e\n",P->Par.me, E->TotalEnergy[0]); 1269 return E->TotalEnergy[0]; 1186 1270 } 1187 1271
Note:
See TracChangeset
for help on using the changeset viewer.