Changeset 32de28
- Timestamp:
- Apr 21, 2008, 2:19:24 PM (17 years ago)
- Children:
- 64fa9e
- Parents:
- 9275a3
- git-author:
- Frederik Heber <heber@…> (04/18/08 14:51:38)
- git-committer:
- Frederik Heber <heber@…> (04/21/08 14:19:24)
- Location:
- pcp/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pcp/src/ions.c
r9275a3 r32de28 61 61 //struct RunStruct *Run = &P->R; 62 62 int i,it,j,IMT,BorAng, d,me, count; 63 struct Lattice *L = &P->Lat; 63 64 int k; 64 struct Lattice *L = &P->Lat;65 65 int relative; // whether read-in coordinate are relative (1) or absolute 66 66 double Bohr = ANGSTROEMINBOHRRADIUS; /* Angstroem */ … … 183 183 } 184 184 } 185 Free(free_name );185 Free(free_name, "IonsInitRead: free_name"); 186 186 I->Max_Max_IonsOfType = 0; 187 187 for (i=0; i < I->Max_Types; i++) 188 188 I->Max_Max_IonsOfType = MAX(I->Max_Max_IonsOfType, I->I[i].Max_IonsOfType); 189 189 I->FTemp = (double *) Malloc(sizeof(double) * NDIM * I->Max_Max_IonsOfType, "IonsInitRead:"); 190 } 191 192 /** Allocates memory for a IonConstrained item and adds to end of list. 193 * \param *I IonType structure 194 * \param ion which ion of the type 195 * \return pointer to created item 196 */ 197 struct IonConstrained * AddConstraintItem(struct IonType *I, int ion) 198 { 199 struct IonConstrained **ptr = &(I->Constraints[ion]); 200 while (*ptr != NULL) { // advance to end of list 201 ptr = &((*ptr)->next); 202 } 203 // allocated memory for structure and items within 204 *ptr = (struct IonConstrained *) Malloc(sizeof(struct IonConstrained), "CreateConstraintItem: IonConstrained"); 205 (*ptr)->R = (double *) Malloc(sizeof(double)*NDIM, "AddConstraintItem: *R"); 206 (*ptr)->U = (double *) Malloc(sizeof(double)*NDIM, "AddConstraintItem: *U"); 207 (*ptr)->next = NULL; 208 return *ptr; 209 } 210 211 /** Removes first of item of IonConstrained list for given \a ion. 212 * Frees memory of items within and then 213 * \param *I IonType structure 214 * \param ion which ion of the type 215 * \return 1 - success, 0 - failure (list is already empty, start pointer was NULL) 216 */ 217 int RemoveConstraintItem(struct IonType *I, int ion) 218 { 219 struct IonConstrained **ptr = &(I->Constraints[ion]); 220 struct IonConstrained *next_ptr; 221 if (*ptr != NULL) { 222 next_ptr = (*ptr)->next; 223 Free((*ptr)->R, "RemoveConstraintItem: R"); 224 Free((*ptr)->U, "RemoveConstraintItem: U"); 225 Free((*ptr), "RemoveConstraintItem: IonConstrained structure"); 226 *ptr = next_ptr; // set start of list to next item (automatically is null if ptr was last item) 227 return 1; 228 } else { 229 return 0; 230 } 190 231 } 191 232 … … 386 427 int i, it; 387 428 for (i=0; i < I->Max_Types; i++) { 388 //fprintf(stderr,"Name\n"); 389 Free(I->I[i].Name); 390 //fprintf(stderr,"Abbreviation\n"); 391 Free(I->I[i].Symbol); 429 Free(I->I[i].Name, "RemoveIonsRead: I->I[i].Name"); 430 Free(I->I[i].Symbol, "RemoveIonsRead: I->I[i].Symbol"); 392 431 for (it=0;it<I->I[i].Max_IonsOfType;it++) { 393 //fprintf(stderr,"sigma[it]\n"); 394 Free(I->I[i].sigma[it]); 395 //fprintf(stderr,"sigma_rezi[it]\n"); 396 Free(I->I[i].sigma_rezi[it]); 397 //fprintf(stderr,"sigma_PAS[it]\n"); 398 Free(I->I[i].sigma_PAS[it]); 399 //fprintf(stderr,"sigma_rezi_PAS[it]\n"); 400 Free(I->I[i].sigma_rezi_PAS[it]); 401 } 402 //fprintf(stderr,"sigma\n"); 403 Free(I->I[i].sigma); 404 //fprintf(stderr,"sigma_rezi\n"); 405 Free(I->I[i].sigma_rezi); 406 //fprintf(stderr,"sigma_PAS\n"); 407 Free(I->I[i].sigma_PAS); 408 //fprintf(stderr,"sigma_rezi_PAS\n"); 409 Free(I->I[i].sigma_rezi_PAS); 410 //fprintf(stderr,"R\n"); 411 Free(I->I[i].R); 412 //fprintf(stderr,"R_old\n"); 413 Free(I->I[i].R_old); 414 //fprintf(stderr,"R_old_old\n"); 415 Free(I->I[i].R_old_old); 416 //fprintf(stderr,"FIon\n"); 417 Free(I->I[i].FIon); 418 //fprintf(stderr,"FIon_old\n"); 419 Free(I->I[i].FIon_old); 420 //fprintf(stderr,"SearchDir\n"); 421 Free(I->I[i].SearchDir); 422 //fprintf(stderr,"GammaA\n"); 423 Free(I->I[i].GammaA); 424 //fprintf(stderr,"FIonL\n"); 425 Free(I->I[i].FIonL); 426 //fprintf(stderr,"FIonNL\n"); 427 Free(I->I[i].FIonNL); 428 //fprintf(stderr,"U\n"); 429 Free(I->I[i].U); 430 //fprintf(stderr,"SFactor\n"); 431 Free(I->I[i].SFactor); 432 //fprintf(stderr,"IMT\n"); 433 Free(I->I[i].IMT); 434 //fprintf(stderr,"FEwald\n"); 435 Free(I->I[i].FEwald); 436 Free(I->I[i].alpha); 437 } 438 //fprintf(stderr,"RLatticeVec\n"); 432 Free(I->I[i].moment[it], "RemoveIonsRead: I->I[i].moment[it]"); 433 Free(I->I[i].sigma[it], "RemoveIonsRead: I->I[i].sigma[it]"); 434 Free(I->I[i].sigma_rezi[it], "RemoveIonsRead: I->I[i].sigma_rezi[it]"); 435 Free(I->I[i].sigma_PAS[it], "RemoveIonsRead: I->I[i].sigma_PAS[it]"); 436 Free(I->I[i].sigma_rezi_PAS[it], "RemoveIonsRead: I->I[i].sigma_rezi_PAS[it]"); 437 while (RemoveConstraintItem(&I->I[i], it)); // empty the constrained item list 438 } 439 Free(I->I[i].sigma, "RemoveIonsRead: I->I[i].sigma"); 440 Free(I->I[i].sigma_rezi, "RemoveIonsRead: I->I[i].sigma_rezi"); 441 Free(I->I[i].sigma_PAS, "RemoveIonsRead: I->I[i].sigma_PAS"); 442 Free(I->I[i].sigma_rezi_PAS, "RemoveIonsRead: I->I[i].sigma_rezi_PAS"); 443 Free(I->I[i].R, "RemoveIonsRead: I->I[i].R"); 444 Free(I->I[i].R_old, "RemoveIonsRead: I->I[i].R_old"); 445 Free(I->I[i].R_old_old, "RemoveIonsRead: I->I[i].R_old_old"); 446 Free(I->I[i].Constraints, "RemoveIonsRead: I->I[i].Constraints"); 447 Free(I->I[i].FIon, "RemoveIonsRead: I->I[i].FIon"); 448 Free(I->I[i].FIon_old, "RemoveIonsRead: I->I[i].FIon_old"); 449 Free(I->I[i].SearchDir, "RemoveIonsRead: I->I[i].SearchDir"); 450 Free(I->I[i].GammaA, "RemoveIonsRead: I->I[i].GammaA"); 451 Free(I->I[i].FIonL, "RemoveIonsRead: I->I[i].FIonL"); 452 Free(I->I[i].FIonNL, "RemoveIonsRead: I->I[i].FIonNL"); 453 Free(I->I[i].FMagnetic, "RemoveIonsRead: I->I[i].FMagnetic"); 454 Free(I->I[i].U, "RemoveIonsRead: I->I[i].U"); 455 Free(I->I[i].SFactor, "RemoveIonsRead: I->I[i].SFactor"); 456 Free(I->I[i].IMT, "RemoveIonsRead: I->I[i].IMT"); 457 Free(I->I[i].FEwald, "RemoveIonsRead: I->I[i].FEwald"); 458 Free(I->I[i].alpha, "RemoveIonsRead: I->I[i].alpha"); 459 } 439 460 if (I->R_cut == 0.0) 440 Free(I->RLatticeVec); 441 //fprintf(stderr,"FTemp\n"); 442 Free(I->FTemp); 443 //fprintf(stderr,"I\n"); 444 Free(I->I); 461 Free(I->RLatticeVec, "RemoveIonsRead: I->RLatticeVec"); 462 Free(I->FTemp, "RemoveIonsRead: I->FTemp"); 463 Free(I->I, "RemoveIonsRead: I->I"); 445 464 } 446 465 -
pcp/src/ions.h
r9275a3 r32de28 38 38 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output 39 39 40 /** Structure containing coordinate and velocity of one ion for a single MD step. 41 * This is an item in a forward-referenced list, such that at each step the current 42 * constrained can be extracted and the item subsequently removed from the list. 43 */ 44 struct IonConstrained { 45 int step; //!< constrained motion for MD step ... 46 double *R; //!< ion coordinates (null if not specified) 47 double *U; //!< ion velocity (null if not specified) 48 enum IonMoveType IMT; //!< Ion MoveType for this step 49 struct IonConstrained *next; //!< pointer to next item in forward-referenced list 50 }; 51 40 52 /** Structure containing data for a single ion type. 41 53 * Contains Mass, atomic number, number of types, coordinates (current and the … … 48 60 int Max_IonsOfType; //!< Maximum number of ions of this type (needed for memory allocation) 49 61 double *R; //!< coordinate (x,y,z) array for all ions of this type R[i][j] (i=x,y,z;j=1,..) 50 double *R_old; //!< (?) Remembers last position (two-dim array, see IonType::R) 51 double *R_old_old; //!< (?) Remembers position before the last one (two-dim array, see IonType::R) 52 double *FIon; //!< (?) Overall force acting on the ion (two-dim array, see IonType::R) 53 double *FIonL; //!< (?) Linear force acting on the ion (two-dim array, see IonType::R) 54 double *FIonNL; //!< (?) Nonlinear force acting on the ion (two-dim array, see IonType::R) 62 double *R_old; //!< Remembers last position (two-dim array, see IonType::R) 63 double *R_old_old; //!< Remembers position before the last one (two-dim array, see IonType::R) 64 struct IonConstrained **Constraints; //!< pointer to each Ion of this IonType with a pointer to the current start item of a list of constrained values 65 double *FIon; //!< Overall force acting on the ion (two-dim array, see IonType::R) 66 double *FIonL; //!< Linear force acting on the ion (two-dim array, see IonType::R) 67 double *FIonNL; //!< Nonlinear force acting on the ion (two-dim array, see IonType::R) 68 double *FEwald; //!< Ewald force (two-dim array, see IonType::R) 69 double *FMagnetic; //!< Magnetic force acting on the ion (two-dim array, see IonType::R) 70 double *FConstraint;//!< Constraint force acting on the ion, needed for Thermostat() (two-dim array, see IonType::R) 55 71 double *U; //!< Velocity of the ion (two-dim array, see IonType::R) 56 double *FIon_old; //!< (?) Remembers prior force acting on the ion (two-dim array, see IonType::R) 57 double *FEwald; //!< (?) Ewald force (two-dim array, see IonType::R) 58 double *FConstraint;//!< Constraint force acting on the ion, needed for Thermostat() (two-dim array, see IonType::R) 72 double *FIon_old; //!< Remembers prior force acting on the ion (two-dim array, see IonType::R) 59 73 double IonFac; //!< mass-like factor in CG structure optimization to determinte step width 60 74 double *GammaA; //!< … … 70 84 char *Name; //!< name of ion's element 71 85 char *Symbol; //!< short form of ion's element 86 double **moment; //!< magnetic moment 72 87 double **sigma; //!< shielding tensor 73 88 double **sigma_rezi; //!< shielding tensor for reciprocal calculation … … 106 121 /* Functions */ 107 122 void IonsInitRead(struct Problem *P, FILE *source); 123 void InitThermostats(struct Problem *P, FILE *source); 108 124 void CalculateEwald(struct Problem *P, int first); 109 125 void RemoveIonsRead(struct Ions *I); … … 111 127 void CalculateIonForce(struct Problem *P); 112 128 void OutputIonForce(struct Problem *P); 129 void ParseIonForce(struct Problem *P); 113 130 void OutputIonCoordinates(struct Problem *P); 114 131 void UpdateIons(struct Problem *P);
Note:
See TracChangeset
for help on using the changeset viewer.