Changeset 9a2c8c for pcp/src/ions.c


Ignore:
Timestamp:
Apr 21, 2008, 2:19:25 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
4782e78
Parents:
8dd187
git-author:
Frederik Heber <heber@…> (04/18/08 16:16:38)
git-committer:
Frederik Heber <heber@…> (04/21/08 14:19:25)
Message:

CorrectForces(): greater fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/ions.c

    r8dd187 r9a2c8c  
    733733
    734734/** Shifts center of gravity of ion forces IonType::FIon.
    735  * First sums up all forces of movable ions to a "force temperature",
    736  * then reduces each force by this temp, so that all in all
     735 * First sums up all forces of movable ions for net center of gravity force,
     736 * then reduces each force by this temp over Ions#Max_TotalIons, so that all in all
    737737 * the net force is 0.
    738738 * \param *P Problem at hand
    739  * \sa CorrectVelocity
    740  * \note why is FTemp not divided by number of ions: is probably correct, but this
    741  *       function was not really meaningful from the beginning.
     739 * \sa CorrectVelocity()
    742740 */
    743741void CorrectForces(struct Problem *P)
     
    746744  double *FIon;
    747745  double FTemp[NDIM];
    748   int is, ia, d;
     746  int is, ia, d, NumIons = 0;
    749747  for (d=0; d<NDIM; d++)
    750     FTemp[d] = 0;
     748    FTemp[d] = 0.;
    751749  for (is=0; is < I->Max_Types; is++) {         // calculate force temperature for each type ...
    752750    for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) {    // .. and each ion of this type ...
    753751      FIon = &I->I[is].FIon[NDIM*ia];
    754       if (I->I[is].IMT[ia] == MoveIon) {                // .. if it's movable
     752      if (I->I[is].IMT[ia] == MoveIon) {                // .. if it's influenced
     753        NumIons++;
    755754                                for (d=0; d<NDIM; d++)
    756755                                  FTemp[d] += FIon[d];
     
    758757    }
    759758  }
     759  //if (P->Files.MeOutMes != 1) return;
     760  //  fprintf(stderr, "TotalForce before: %e\t %e\t %e\n", FTemp[0], FTemp[1], FTemp[2]);
    760761  for (is=0; is < I->Max_Types; is++) {         // and then reduce each by this value
    761762    for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) {
     
    763764      if (I->I[is].IMT[ia] == MoveIon) {
    764765                                for (d=0; d<NDIM; d++)
    765                                  FIon[d] -= FTemp[d];                                           // (?) why not -= FTemp[d]/I->Max_TotalIons
    766       }
    767     }
    768   }
     766                                 FIon[d] -= FTemp[d]/NumIons;
     767      }
     768    }
     769  }
     770/*  for (d=0; d<NDIM; d++)
     771    FTemp[d] = 0.;
     772  for (is=0; is < I->Max_Types; is++) {         // calculate force temperature for each type ...
     773    for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) {    // .. and each ion of this type ...
     774      FIon = &I->I[is].FIon[NDIM*ia];
     775      if (I->I[is].IMT[ia] == MoveIon) {                // .. if it's influenced
     776                                for (d=0; d<NDIM; d++)
     777                                  FTemp[d] += FIon[d];
     778      }
     779    }
     780  }
     781  if (P->Files.MeOutMes != 1) return;
     782    fprintf(stderr, "TotalForce after: %e\t %e\t %e\n", FTemp[0], FTemp[1], FTemp[2]);
     783    */
    769784}
    770785
Note: See TracChangeset for help on using the changeset viewer.