예제 #1
0
void AbaqusUserMaterial :: give3dMaterialStiffnessMatrix(FloatMatrix &answer,
                                                         MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)
{
    AbaqusUserMaterialStatus *ms = dynamic_cast< AbaqusUserMaterialStatus * >( this->giveStatus(gp) );
    if ( !ms->hasTangent() ) { ///@todo Make this hack fit more nicely into OOFEM in general;
        // Evaluating the function once, so that the tangent can be obtained.
        FloatArray stress(6), strain(6);
        strain.zero();
        this->giveRealStressVector_3d(stress, gp, strain, tStep);
    }

    answer = ms->giveTempTangent();

#if 0
    double h = 1e-7;
    FloatArray strain, strainh, stress, stressh;
    strain = static_cast< StructuralMaterialStatus * >( gp->giveMaterialStatus() )->giveTempStrainVector();
    stress = static_cast< StructuralMaterialStatus * >( gp->giveMaterialStatus() )->giveTempStressVector();
    FloatMatrix En( strain.giveSize(), strain.giveSize() );
    for ( int i = 1; i <= strain.giveSize(); ++i ) {
        strainh = strain;
        strainh.at(i) += h;
        this->giveRealStressVector_3d(stressh, form, gp, strainh, tStep);
        stressh.subtract(stress);
        stressh.times(1.0 / h);
        En.setColumn(stressh, i);
    }
    this->giveRealStressVector_3d(stress, form, gp, strain, tStep);

    printf("En = ");
    En.printYourself();
    printf("Tangent = ");
    answer.printYourself();
#endif
}
예제 #2
0
void AbaqusUserMaterial :: give3dMaterialStiffnessMatrix_dPdF(FloatMatrix &answer,
                                                              MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)
{
    AbaqusUserMaterialStatus *ms = dynamic_cast< AbaqusUserMaterialStatus * >( this->giveStatus(gp) );
    if ( !ms->hasTangent() ) { ///@todo Make this hack fit more nicely into OOFEM in general;
        // Evaluating the function once, so that the tangent can be obtained.
        FloatArray stress, vF;
        vF = ms->giveTempFVector();
        this->giveFirstPKStressVector_3d(stress, gp, vF, tStep);
    }

    if ( !mUseNumericalTangent ) {
        //    if(mStressInterpretation == 0) {
        answer = ms->giveTempTangent();
        /*
         *  }
         *  else {
         *              // The Abaqus Documentation of User Subroutines for UMAT Section 1.1.31 says that DDSDDE is defined as
         *              // partial(Delta(sigma))/partial(Delta(epsilon)).
         *              FloatMatrix dSdE;
         *              dSdE = ms->giveTempTangent();
         *              this->give_dPdF_from(dSdE, answer, gp);
         *  }
         */
    } else   {
        double h = mPerturbation;
        FloatArray vF, vF_h, stress, stressh;
        vF = ms->giveTempFVector();
        stress = ( ( StructuralMaterialStatus * ) gp->giveMaterialStatus() )->giveTempPVector();
        FloatMatrix En(9, 9);
        for ( int i = 1; i <= 9; ++i ) {
            vF_h = vF;
            vF_h.at(i) += h;
            this->giveFirstPKStressVector_3d(stressh, gp, vF_h, tStep);
            stressh.subtract(stress);
            stressh.times(1.0 / h);
            En.setColumn(stressh, i);
        }

        // Reset
        this->giveFirstPKStressVector_3d(stressh, gp, vF, tStep);

        /*
         *      printf("En = ");
         *      En.printYourself();
         *
         *      answer = ms->giveTempTangent();
         *      printf("Tangent = ");
         *      answer.printYourself();
         *
         *      FloatMatrix diff = En;
         *      diff.subtract(answer);
         *      printf("diff: "); diff.printYourself();
         */

        answer = En;
    }
}
예제 #3
0
void AbaqusUserMaterial :: giveCharacteristicMatrix(FloatMatrix &answer,
                                                    MatResponseForm form, MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)
{
    AbaqusUserMaterialStatus *ms = dynamic_cast< AbaqusUserMaterialStatus * >( this->giveStatus(gp) );
    if ( ~ms->hasTangent() ) { ///@todo Make this hack fit more nicely into OOFEM in general;
        // Evaluating the function once, so that the tangent can be obtained.
        MaterialMode mMode = gp->giveMaterialMode();
        int ncomp = 0;
        if ( mMode == _3dMat ) {
            ncomp = 6;
        } else if ( mMode == _PlaneStress ) {
            ncomp = 3;
        } else if ( mMode == _PlaneStrain ) {
            ncomp = 4;
        } /*else if ( mMode == _3dMat_F ) {
           * ncomp = 9;
           * } */
        else if ( mMode == _1dMat ) {
            ncomp = 1;
        }

        FloatArray stress(ncomp), strain(ncomp);
        strain.zero();
        this->giveRealStressVector(stress, form, gp, strain, tStep);
    }

    answer = ms->giveTempTangent();

#if 0
    double h = 1e-7;
    FloatArray strain, strainh, stress, stressh;
    strain = ( ( StructuralMaterialStatus * ) gp->giveMaterialStatus(AbaqusUserMaterialClass) )->giveTempStrainVector();
    stress = ( ( StructuralMaterialStatus * ) gp->giveMaterialStatus(AbaqusUserMaterialClass) )->giveTempStressVector();
    FloatMatrix En( strain.giveSize(), strain.giveSize() );
    for ( int i = 1; i <= strain.giveSize(); ++i ) {
        strainh = strain;
        strainh.at(i) += h;
        this->giveRealStressVector(stressh, form, gp, strainh, tStep);
        stressh.subtract(stress);
        stressh.times(1.0 / h);
        En.setColumn(stressh, i);
    }

    printf("En = ");
    En.printYourself();
    printf("Tangent = ");
    answer.printYourself();
#endif
}
예제 #4
0
double RkPdf::EfRk(const double& x, const double& tau){
  const double r_ckak = ck/ak;
  return (x<0.0 ? 0.5*(1-r_ckak)*En(x,tau*(ak-ck)) : 0.5*(1+r_ckak)*Ep(x, tau*(ak+ck)));
}
예제 #5
0
파일: FRE_FAC.CPP 프로젝트: pyal/eos_cpp
//   double Sound(double Dencity,double Energy);
double MatterFreeE::Temperature(double Dencity,double Energy)
  {
    VecCl Den(1),En(1),Temper(1);Den[1]=Dencity;En[1]=Energy;
    Temperature(Temper.Ptr,Den.Ptr,En.Ptr,1);
    return Temper[1];
  }
예제 #6
0
void IDPNagato::sinc()
{
  //char fname_energy[64]; sprintf(fname_energy, ftemp_energy, 0);
  //ofstream ofs_energy(fname_energy);
  //ofstream ofs_r1_st(fname_r1_sinc_st), ofs_r1_ev(fname_r1_sinc_ev);
  //ofstream ofs_r2_st(fname_r2_sinc_st), ofs_r2_ev(fname_r2_sinc_ev);
  //ofstream ofs_endeffector(fname_sinc_endeffector);
  ofstream ofs_energy(fname_lst[eENERGY][eSinc][eName]);
  ofstream ofs_r1_st(fname_lst[eGRAPH_ST_R1][eSinc][eName]);
  ofstream ofs_r1_ev(fname_lst[eGRAPH_EV_R1][eSinc][eName]);
  ofstream ofs_r2_st(fname_lst[eGRAPH_ST_R2][eSinc][eName]);
  ofstream ofs_r2_ev(fname_lst[eGRAPH_EV_R2][eSinc][eName]);
  ofstream ofs_endeffector(fname_lst[eGRAPH_ENDEFFECTOR][eSinc][eName]);
  
  //  FILE* fp_energy = fopen(fname_energy,"w");
  //printf("line=%d %s\n", __LINE__, fname_r1_sinc_st);
  //printf("line=%d %s\n", __LINE__, fname_r2_sinc_st);
  //printf("line=%d %s\n", __LINE__, fname_r1_sinc_ev);
  printf("line=%d %s\n", __LINE__
	 , fname_lst[eGRAPH_ST_R1][eSinc][eName]);
  printf("line=%d %s\n", __LINE__
	 , fname_lst[eGRAPH_EV_R1][eSinc][eName]);
  printf("line=%d %s\n", __LINE__
	 , fname_lst[eGRAPH_ST_R2][eSinc][eName]);
  printf("line=%d %s\n", __LINE__
	 , fname_lst[eGRAPH_EV_R2][eSinc][eName]);
  sleep(2);
  
  double t = 0;
  for(nt = 0; nt <= static_cast<int>(Ts/dt); ++nt )
    {
      graph_standard(ofs_r1_st, t,
		     r1.th, r1.thv, r1.tha,
		     e1.ev, e1.ia, e1.tau,
		     e1.energy, e1.ev*e1.ia);
      graph_volt_constituent(ofs_r1_ev, t, e1.ev,
			     b1*r1.thv, b2*r1.tha, b3*e1.tau);
        
      graph_standard(ofs_r2_st, t,
		     r2.th, r2.thv, r2.tha,
		     e2.ev, e2.ia, e2.tau,
		     e2.energy, e2.ev*e2.ia);
      graph_volt_constituent(ofs_r2_ev, t, e2.ev,
			     b1*r2.thv, b2*r2.tha, b3*e2.tau);
      
      graph_endeffector(ofs_endeffector,  t, v1, r3);
      
      t = t + dt;
      v1.th  = sc.sin_th1(t);
      v1.thv = sc.sin_th1v(t);
      v1.tha = sc.sin_th1a(t);

      enemin2 = En();
      // if (nt < nt11){ enemin2 = En1(); }
      // if (nt >= nt11 && nt < nt22){ enemin2 = En2(); }
      // if (nt >= nt22){ enemin2 = En3(); }
      
      ofs_energy << t <<" "<< enemin2 << endl;
      //      fprintf(fp_energy, "%8.4lf %8.4lf\n", t, enemin2 );

      if (nt % 10 == 0)
	{
	  //char fname[4][64];
	  //sprintf(fname[1], ftemp_sinc_e[1], nt);
	  //sprintf(fname[2], ftemp_sinc_e[2], nt);	
	  //sprintf(fname[3], ftemp_sinc_e[3], nt);
	  sprintf(fname_lst[eZU_E1][eSinc][eName],
		  fname_lst[eZU_E1][eSinc][eTemp], nt);
	  sprintf(fname_lst[eZU_E2][eSinc][eName],
		  fname_lst[eZU_E2][eSinc][eTemp], nt);
	  sprintf(fname_lst[eZU_E3][eSinc][eName],
		  fname_lst[eZU_E3][eSinc][eTemp], nt);
	  
	  ofstream ofs1(fname_lst[eZU_E1][eSinc][eName]);
	  ofstream ofs2(fname_lst[eZU_E2][eSinc][eName]);
	  ofstream ofs3(fname_lst[eZU_E3][eSinc][eName]);
	  //zu( ofs1 ); all in
	  //zu( ofs1, ofs2 );
	  zu( ofs1, ofs2, ofs3 );// !not implement
	}
      // output volt ampere field
      // plot("");
    }
  //assert(false);
}
예제 #7
0
void IDPDIRECT::sinc()
{
  //char fname_energy[64]; sprintf(fname_energy, ftemp_energy, 0);
  ofstream ofs_energy(fname_lst[eENERGY][eSinc][eName]     );
  ofstream ofs_r1_st (fname_lst[eGRAPH_ST_R1][eSinc][eName]);
  ofstream ofs_r1_ev (fname_lst[eGRAPH_EV_R1][eSinc][eName]);
  ofstream ofs_r2_st (fname_lst[eGRAPH_ST_R2][eSinc][eName]);
  ofstream ofs_r2_ev (fname_lst[eGRAPH_ST_R2][eSinc][eName]);
  ofstream ofs_r3_st (fname_lst[eGRAPH_ST_R3][eSinc][eName]);
  ofstream ofs_r3_ev (fname_lst[eGRAPH_ST_R3][eSinc][eName]);
  
  //  FILE* fp_energy = fopen(fname_energy,"w");
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_ST_R1][eSinc][eName]);
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_EV_R1][eSinc][eName]);
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_ST_R2][eSinc][eName]);
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_EV_R2][eSinc][eName]);
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_ST_R3][eSinc][eName]);
  printf("line=%d %s\n", __LINE__, fname_lst[eGRAPH_EV_R3][eSinc][eName]);
  
  double t = 0;
  for( int i = 0; i <= static_cast<int>(Ts/dt); ++i )
    {
      graph_standard(ofs_r1_st, t,
		     r1.th, r1.thv, r1.tha,
		     e1.ev, e1.ia, e1.tau,
		     e1.energy, e1.ev*e1.ia);
      graph_volt_constituent(ofs_r1_ev, t, e1.ev,
			     b1*r1.thv, b2*r1.tha, b3*e1.tau);
      // --------------------------------------------------
      graph_standard(ofs_r2_st, t,
		     r2.th, r2.thv, r2.tha,
		     e2.ev, e2.ia, e2.tau,
		     e2.energy, e2.ev*e2.ia);
      graph_volt_constituent(ofs_r2_ev, t, e2.ev,
			     b1*r2.thv, b2*r2.tha, b3*e2.tau);
      // --------------------------------------------------
      graph_standard(ofs_r3_st, t,
		     r3.z0, r3.Thv(), r3.Tha(),
		     e3.ev, e3.ia, e3.tau,
		     e3.energy, e3.ev*e3.ia);
      graph_volt_constituent(ofs_r3_ev, t, e3.ev,
			     b1*r3.Thv(), b2*r3.Tha(), b3*e3.tau);
      // --------------------------------------------------
      t = t + dt;
      v1.th  = sc.sin_th1(t);
      v1.thv = sc.sin_th1v(t);
      v1.tha = sc.sin_th1a(t);
      enemin2 = En();

      ofs_energy << t <<" "<< enemin2 << endl;
      //      fprintf(fp_energy, "%8.4lf %8.4lf\n", t, enemin2 );

      if (i % 10 == 0)
	{
	  sprintf(fname_lst[eZU_E1][eSinc][eName],
		  fname_lst[eZU_E1][eSinc][eTemp], i);
	  sprintf(fname_lst[eZU_E2][eSinc][eName],
		  fname_lst[eZU_E2][eSinc][eTemp], i);
	  sprintf(fname_lst[eZU_E3][eSinc][eName],
		  fname_lst[eZU_E3][eSinc][eTemp], i);
	  
	  ofstream ofs1(fname_lst[eZU_E1][eSinc][eName]);
	  ofstream ofs2(fname_lst[eZU_E2][eSinc][eName]);
	  ofstream ofs2(fname_lst[eZU_E3][eSinc][eName]);
	  // ofstream ofs3(fname_lst[eZU_E2][eSinc][eName]);
	  //zu( ofs1 ); all in
	  //zu( ofs1, ofs2 );
	  zu( ofs1, ofs2, ofs3 );// !not implement
	}
      // output volt ampere field
      // plot("");
    }
}
예제 #8
0
int main(){
	double lightspeed, Newton_G, mass;
	double R_sch; 
	double xp[STEPS], yp[STEPS][NVAR], Ene[STEPS];
	double apo, per, Va, Vp, E, AngMom, Vc, ecc, mjAxis;
	double rIni, vIni, T;
	int i, j, k, loop;
	double y1[NVAR], y[NVAR], Ene1, x1, x2, xbin, xend, delX;
	double eps, h0, hmax;
	inData data;
	void *custom_data = &data;
	int flag, nvar;
	fluxfn fn;
	fluxEn En;
	FILE *fp;
	char *str;
	char str1[] = "result_NT";
	char str2[] = "result_WG";
	char str3[] = "result_SG";
	char str4[] = "result_GN";

// Integration-----------------------------------------------------------
	lightspeed = 10;
	Newton_G = 1;
	mass = 1e6;
	R_sch = 2 * Newton_G * mass / dSqr(lightspeed);

	per = 5.0 * R_sch;
	ecc = 0.998;
	apo = (1 + ecc) / (1 - ecc) * per;
	mjAxis = (per + apo) / 2.0;
	E = -0.5 * Newton_G * mass / mjAxis;
	Va = pow(2 * (E + (Newton_G * mass / apo)), 0.5);
	Vp = pow(2 * (E + (Newton_G * mass / per)), 0.5);

	rIni = apo;
	vIni = Va;
//	rIni = per;
//	vIni = Vp;
	AngMom = rIni * vIni;
	T = 2.0 * PI * pow(mjAxis, 1.5) * pow((Newton_G * mass), -0.5);
	Vc = pow((Newton_G * mass / rIni), 0.5);
	
/*	rIni = 10000.0;
	vIni = 4;
	E = 0.5 * vIni*vIni - (Newton_G * mass / rIni);
	AngMom = rIni * vIni;
	mjAxis = -1.0 * Newton_G * mass / (2 * E);
	ecc = pow((1.0 - dSqr(AngMom) / (Newton_G * mass * mjAxis)), 0.5);
	apo = mjAxis * (1.0 + ecc);
	per = mjAxis * (1.0 - ecc);
	T = 2.0 * PI * pow(mjAxis, 1.5) * pow((Newton_G * mass), -0.5);
	Vc = pow((Newton_G * mass / rIni), 0.5);
*/

for(loop = 1; loop <= 4; loop++){	
	switch (loop){
		case 1:
			fn = F_NT;
			En = E_NT;
			str = &str1[0];
			break;
		case 2:
			fn = F_WG;
			En = E_WG;
			str = &str2[0];
			break;
		case 3:
			fn = F_SG;
			En = E_SG;
			str = &str3[0];
			break;
		case 4:
			fn = F_GN;
			En = E_GN;
			str = &str4[0];
			break;
	}
	printf("%s\n", str);


	x1 = 0;
	x2 = 6.0 * T;
	delX = (x2 - x1) / STEPS;
	eps = 1e-13;
	hmax = delX / HACCU;
	h0 = 1e-10;
	nvar = NVAR;
	data.mass = mass;
	data.lightspeed = lightspeed;
	data.Newton_G = Newton_G;

	for(i = 0; i < NVAR; i++){
		y1[i] = 0;
	}
	y1[1] = -1.0 * rIni;
	y1[2] = vIni;
	for(i = 0; i < NVAR; i++){
		y[i] = y1[i];
	}
	Ene1 = En(nvar, y, custom_data);
// Run--------------------------------------------------------------
	for(i = 0; i < STEPS; i++){
		xbin = x1 + delX * i;
		xend = x1 + delX * (i + 1);
		flag = dopri8(fn, nvar, xbin, y, xend, eps, hmax, &h0, NULL, NULL, custom_data);
		if(flag == 0) printf("!!%d\n", i);
		Ene[i] = En(nvar, y, custom_data);
		for(j = 0; j < NVAR; j++) yp[i][j] = y[j];
		xp[i] = xend;
	}	

	fp = fopen(str,"w+");
	if(fp == NULL)
		printf("Cannot open the file!\n");
	
	fprintf(fp, "%10.6f \t", x1);
	for(j = 0; j < NVAR; j++){
		fprintf(fp, "%20.15f \t", y1[j]);
	}
	fprintf(fp, "%20.15f \n", Ene1);
	for(i = 0; i < STEPS; i++){
		fprintf(fp, "%10.6f \t", xp[i]);
		for(j = 0; j < NVAR; j++){
			fprintf(fp, "%20.15f \t", yp[i][j]);
		}
		fprintf(fp, "%20.15f \n", Ene[i]);
	}
	fclose(fp);
}
	
	printf("END-----------------------------------\n");
	printf("R_sch = %e, Vc = %e\n", R_sch, Vc);
	printf("apo = %e, per = %e, ecc = %e, mjAxis = %e\n", apo, per, ecc, mjAxis);
	printf("Va = %e, Vp = %e\n", Va, Vp);
	printf("Initial quantities:\n");
	printf("rIni = %e, vIni = %e, T = %e\n", rIni, vIni, T);
	printf("E = %e, apo = %e\n", E, apo);
}