예제 #1
0
Atom::~Atom()
{
  if (nmax) {
    destroy_2d_double_array(x);
    destroy_2d_double_array(v);
    destroy_2d_double_array(f);
    destroy_2d_double_array(vold);
  }
}
예제 #2
0
파일: main.cpp 프로젝트: xurui1/SCFT_1D_ABA
int main( ){
    
    double **w;
    double *eta;
    double **phi;
    double *chi;
    double *f;
    double *mu;
    double ds;
    int *Ns;
    double dr;
    double volume;
    double **chiMatrix;
    double fE_hom;
    //int secantmod;
    
    //secantmod=1;
    
    //Allocate memory
    w=create_2d_double_array(ChainType,Nr,"w");          //Auxiliary potential fields
    eta=create_1d_double_array(Nr,"eta");                //Incompressibility field
    phi=create_2d_double_array(ChainType,Nr,"phi");      //Concentration fields
    chi=create_1d_double_array(ChainType,"chi");            //Interaction parameters
    f=create_1d_double_array(ChainType,"f");                //Chain fractions
    Ns=create_1d_integer_array(ChainType, "Ns");            //Chain lengths
    mu=create_1d_double_array(3, "mu");                     //Chemical potentials
    chiMatrix=create_2d_double_array(ChainType,ChainType,"chiMatrix");
    
    //Initial time for random number generator
    long iseed;
    time_t t;
    iseed=time(&t);
    srand48(iseed);
    
    //Set parameters
    parameters(chi,f,&ds,Ns,&dr,mu);
    Xmatrix(chiMatrix,chi);
    volume=vol(dr);
    
    //Calculate homogeneous free energy
    //fE_hom=homofE(chiMatrix);
    //fE_hom=homogfE(mu,chiMatrix,f);
    
    //Set up initial omega field
    omega(w);
    
    //Determine muC for tensionless membrane
    //if (secantmod==1){secant(w,phi,eta,Ns,ds,chi,dr,chiMatrix,mu,volume,f);}
    
    //SCFT
    FreeEnergy(w,phi,eta,Ns,ds,chi,dr,chiMatrix,mu,volume,f);
    
    //Destroy memory allocations------------
    destroy_2d_double_array(w);
    destroy_1d_double_array(eta);
    destroy_2d_double_array(phi);
    destroy_1d_double_array(chi);
    destroy_1d_integer_array(Ns);
    destroy_1d_double_array(f);
    destroy_2d_double_array(chiMatrix);
    //-------------------------------------
    
    return 0;
}