float Ship::Wm(){
	float c1, c2;
	c1 = c2 = 0.;

	float PdV = Pd(v.Vk)/Vol();
	float c3 = pow(v.Year, 0.4) - 19;
	if (PdV > 40)
		c1 = 0.14 * c3;
	else if (PdV > 26)
		c1 = 0.13 * c3;
	else if (PdV > 21)
		c1 = 0.21 * c3;
	else if (PdV > 10)
		c1 = 0.22 * c3;
	else c1 = 1.;

	if (Vol() > 5000)
        c1 = 1.;

	if (v.Year < 1915)
		c2 = 1.9;
	else if(v.Year < 1933)
		c2 = 1.6;
	else c2 = 0.92;

	return find(et, e.Eng).K1 * pow(Pd(v.Vk), find(et, e.Eng).K2)* (pow((pow(v.Year, 0.45) - 29.3), 2.) + 0.45) * c1 * c2 * find(st, e.Gear).Wgear;
}
Esempio n. 2
0
void CIndicator::Render(std::vector<struct kline_struct>* pvData)
{
	m_pvData = pvData;
	
	

	if (!m_pRender)
		return;

	m_pRender->BeginRender(m_rcArea);

	if (m_nIndicatorType == INDICATOR_TYPE_MA)
	{
		KLine();
		

	}
	else if (m_nIndicatorType == INDICATOR_TYPE_VOL)
	{
		Vol();		
	}
	else
	{
		CColorUtil clr(0, 0, 255);
		m_pRender->DrawRectangle(m_rcMemDC, clr);

		m_pRender->DrawText(m_rcMemDC, _T("macd"), clr);
	}

	m_pRender->EndRender();
}
Esempio n. 3
0
params::params(char *address)
{
  //read data from input file
  std::ifstream param(address);
  
  std::ostringstream param_trimmed_out;
  std::string input_line;
  while (!param.eof())
    {
      std::getline(param,input_line);
      if ((int(input_line[0])!=0)&&(int(input_line[0])!=35)) param_trimmed_out<<input_line<<std::endl;
    }
  param.close();
  
  std::istringstream param_trimmed_in(param_trimmed_out.str());  
  
  param_trimmed_in>>IsBox_;
  param_trimmed_in>>Nx_tot_>>Ny_tot_>>Nz_tot_;
  param_trimmed_in>>Lx_>>Ly_>>Lz_;
  param_trimmed_in>>bs_;
  param_trimmed_in>>Np_track_;
  param_trimmed_in>>T_final_>>dt_>>threshold_;
  param_trimmed_in>>Statistics_>>Stat_print_;
  param_trimmed_in>>Data_freq_fast_>>Data_freq_slow_;
  param_trimmed_in>>Data_dir_>>Stat_dir_;
  param_trimmed_in>>Initial_;
  param_trimmed_in>>PreCond_>>Solver_;
  param_trimmed_in>>cooling_;
  param_trimmed_in>>Iteration1_>>Iteration2_>>epsilon_;
  param_trimmed_in>>TWC_>>ParticleGravity_;
  param_trimmed_in>>A1_>>A2_;
  param_trimmed_in>>Rho0_;
  param_trimmed_in>>U0_;
  param_trimmed_in>>T0_;
  param_trimmed_in>>Mu0_>>k_;
  param_trimmed_in>>gx1_>>gy1_>>gz1_>>gx2_>>gy2_>>gz2_;
  param_trimmed_in>>Cp_>>Cv_;
  param_trimmed_in>>np0_;
  param_trimmed_in>>Dp_>>Rhop_;
  param_trimmed_in>>Cvp_;
  param_trimmed_in>>epsilonp_;
  param_trimmed_in>>Nu_;
  param_trimmed_in>>I01_>>I02_;
  
  //initially update parameters
  R_ = Cp_ - Cv_;
  P0_ = Rho0_ * T0_ * R_;
  Tp_ = Rhop_ * Dp_ * Dp_ / ( 18 * Mu0_ );
  mp_ = Rhop_ * PI * Dp_ * Dp_ * Dp_ / 6.;
  W_ = Ly_;
  N0_ = (int)(np0_*Vol());

  Iteration_ = Iteration1_;
  A_ = A1_;
  gx_ = gx1_;
  gy_ = gy1_;
  gz_ = gz1_;
  I0_ = I01_;
}
float Ship::Bunker(){
	float b1 = v.Range / (1. + 0.4 * v.Coalpct);
	float b2 = 0.;
	float b3 = 1.8/Pd(v.Vc) * v.Range * v.Vc * 0.1;

	if (v.Year < 1898 || e.Eng == QuadExp || e.Eng == TripExp)
		b2 = 1. - (1910 - v.Year)/70.;
	else if (v.Year < 1920)
		b2 = 1. + (v.Year - 1910)/20.;
	else if( v.Year < 1950)
		b2 = 1.5 + (v.Year - 1920)/60.;
	else
		b2 = 2 + (v.Year - 1950)/60.;

	float c1 = (Pd(v.Vk)/Vol() > 15 && Pd(v.Vk)/Vol() < 18) ? 0.3 : 1;
	return (b1 / (b2 * b3) + 0.005 * Vol()) * c1 * find(et, e.Eng).FcE * find(st, e.Gear).FcT;
}
float Ship::t(){
	float M = v.Lpp / pow(Vol(), 1./3.);

	int Fa;
	switch(e.Faa){
		case N: Fa = 0; break;
		case U: Fa = -2; break;
		case V: Fa = 2; break;
		default: Fa = 0;
	}

	float BL = v.B / v.Lpp;

	float d = 0.625 * BL + 0.08;
	float e = 0.165 - 0.25 * BL;
	float f = 525. - 8060. * BL + 20300. * pow(BL, 2.);

	float t1 = d + e / (f * pow(0.98 - Cb(), 3.) + 1.);
	float t2 = -0.01 * Fa;
	float t3 = 2. * (Dprop()/v.Lpp - 0.04);

	return t1 + t2 + t3 - 0.26 + 0.04 * M;
}
float Ship::w(){
	float M = v.Lpp / pow(Vol(), 1./3.);

	int Fa;
	switch(e.Faa){
		case N: Fa = 0; break;
		case U: Fa = -2; break;
		case V: Fa = 2; break;
		default: Fa = 0;
	}

	float BL = v.B / v.Lpp;

	float a = 0.1 * BL + 0.149;
	float b = 0.05 * BL + 0.449;
	float c = 585. - 5027. * BL + 11700. * pow(BL, 2.);

	float w1 = a + b / (c * pow(0.98 - Cb(), 3.) + 1);
	float w2 = 0.025 * Fa / (100. * pow(Cb() - 0.7, 2.) + 1);
	float w3 = min(0.1, -0.18 + 0.00756 / (Dprop()/v.Lpp + 0.002));

	float S1 = e.Shafts > 1 ? 1. : 0.7;
	return 0.7 * (w1 + w2 + w3) - 0.45 + 0.08 * M * S1;
}
float Ship::Flotation(){
	float c1 = Stability() > 1 ? sqrt(Stability()) : pow(Stability(), 4.);
	float c4 = v.Year < 1850 ? 0.4 : (v.Year > 1890 ? 1 : 1 - 3. * (1890 - v.Year) / 200.);
	return (WPA() / 35. + Vol()) / 2. * c1 * c4;
}
void Ship::output(){
	ofstream file;
	file.open("Report.txt");
	file << "[table]" << endl;

	cout << fixed << setprecision(2) << "Length: \t\t\t\t" << v.Lpp << " m" << endl;
	file << fixed << setprecision(2) << "[tr][td]Length: \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[/td][td]" << v.Lpp << " m[/td][/tr]" << endl;
	cout << "Beam: \t\t\t\t\t" << v.B << " m" << endl;
	file << "[tr][td]Beam: [/td][td]" << v.B << " m[/td][/tr]" << endl;
	cout << "Draft: \t\t\t\t\t" << v.D << " m" << endl;
	file << "[tr][td]Draft: [/td][td]" << v.D << " m[/td][/tr]" << endl;
	cout << "Freeboard: \t\t\t\t" << v.fB << " m" << endl;
	file << "[tr][td]Freeboard: [/td][td]" << v.fB << " m[/td][/tr]" << endl;
	cout << setprecision(3) << "Block Coefficient: \t\t\t" << Cb() << endl;
	file << setprecision(3) << "[tr][td]Block Coefficient: [/td][td]" << Cb() << "[/td][/tr]" << endl;
	cout << setprecision(0) << "Displacement: \t\t\t\t" << Vol() << " t" << endl;
	file << setprecision(0) << "[tr][td]Displacement: [/td][td]" << Vol() << " t[/td][/tr]" << endl;
	cout << "Lightship: \t\t\t\t" << Wh() + Wwo() + Wm() + We() + Wspus() + Bunker() << " t" << endl;
	file << "[tr][td]Lightship: [/td][td]" << Lightship() << " t[/td][/tr]" << endl;

	cout << setprecision(1) << "\nMax Speed: \t\t\t\t" << v.Vk << " kn" << endl;
	file << setprecision(1) << "\n[tr][td]Max Speed: [/td][td]" << v.Vk << " kn[/td][/tr]" << endl;
	cout << "Cruise Speed: \t\t\t\t" << v.Vc << " kn / " << v.Range << " nm" << endl;
	file << "[tr][td]Cruise Speed: [/td][td]" << v.Vc << " kn / " << v.Range << " nm[/td][/tr]" << endl;

	cout << "Engine: \t\t\t\t";
	file << "[tr][td]Engine: [/td][td]";
	switch(e.Gear){
		case Direct:
            cout << "Direct ";
            file << "Direct ";
            break;
		case Geared:
		    cout << "Geared ";
		    file << "Geared ";
		    break;
		case Turbo_Electric:
		    cout << "Turbo-Electric ";
		    file << "Turbo-Electric ";
            break;
		default:
            cout << "Unknown";
            file << "Unknown";
	}
	switch(e.Eng){
		case Diesel2stk:
		    cout << "Two Stroke Diesel" << endl;
		    file << "Two Stroke Diesel";
		    break;
		case Diesel4stk:
		    cout << "Four Stroke Diesel" << endl;
		    file << "Four Stroke Diesel" << endl;
		    break;
		case QuadExp:
		    cout << "Quadruple Expansion Reciprocating Engine" << endl;
		    file << "Quadruple Expansion Reciprocating Engine";
		    break;
		case TripExp:
		    cout << "Triple Expansion Reciprocating Engine" << endl;
		    file << "Triple Expansion Reciprocating Engine";
		    break;
		case SimExp:
		    cout << "Simple Reciprocating Engine" << endl;
		    file << "Simple Reciprocating Engine";
		    break;
		case SteamTur:
		    cout << "Steam Turbine" << endl;
		    file << "Steam Turbine";
		    break;
		default:
            cout << endl;
	}
	file << "[/td][/tr]" << endl;

	cout << setprecision(0) << "Power Delivered: \t\t\t" << Pd(v.Vk) << " hp" << endl;
	file << setprecision(0) << "[tr][td]Power Delivered: [/td][td]" << Pd(v.Vk) << " hp[/td][/tr]" << endl;
	cout << setprecision(2) << "Total Efficiency: \t\t\t" << NUt()*100 << "%" << endl;
	file << setprecision(2) << "[tr][td]Total Efficiency: [/td][td]" << NUt()*100 << "%[/td][/tr]" << endl;
	cout << setprecision(3) << "Froude Number: \t\t\t\t" << Fn() << endl;
	file << setprecision(3) << "[tr][td]Froude Number: [/td][td]" << Fn()  << "[/td][/tr]" << endl;
	cout << setprecision(0) << "Bunker Size: \t\t\t\t" << Bunker() << " t" << endl;
	file << setprecision(0) << "[tr][td]Bunker Size: [/td][td]" << Bunker() << " t[/td][/tr]" << endl;
	cout << "Service Allowance: \t\t\t" << e.SA << "%" << endl;
	file << "[tr][td]Service Allowance: [/td][td]" << e.SA << "%[/td][/tr]" << endl;

	cout << setprecision(2);
	file << setprecision(2);
	cout << "Length of Superstructure: \t\t" << v.Lspus << " m" << endl;
	file << "[tr][td]Length of Superstructure: [/td][td]" << v.Lspus << " m[/td][/tr]" << endl;

	cout << "Aftbody Shape: \t\t\t\t";
	file << "[tr][td]Aftbody Shape: [/td][td]";
	switch(e.Faa){
		case V:
		    cout << "V" << endl;
		    file << "V";
		    break;
		case U:
		    cout << "U" << endl;
		    file << "U";
		    break;
		case N:
		    cout << "N" << endl;
		    file << "N";
		    break;
		default:
		    cout << "N" << endl;
		    file << "N";
	}
	file << "[/td][/tr]";

	cout << "\nLongitudinal Center of Buoyancy: \t" << lcb() << "%" << endl;
	file << "\n[tr][td]Longitudinal Center of Buoyancy: [/td][td]" << lcb() << "% / " << lcb()*v.Lpp << " m from midpoint[/td][/tr]" << endl;
	cout << "Longitudinal Center of Gravity: \t" << lcg() << "%" << endl;
	file << "[tr][td]Longitudinal Center of Gravity: [/td][td]" << lcg() << "% / " << lcg()*v.Lpp << " m from midpoint[/td][/tr]" << endl;

	cout << "Vertical Center of Gravity: \t\t" << KGh() << " m" << endl;
	file << "[tr][td]Vertical Center of Gravity: [/td][td]" << KGh() << " m[/td][/tr]" << endl;
	cout << "Metacentric Height: \t\t\t" << GM() << " m" << endl;
	file << "[tr][td]Metacentric Height: [/td][td]" << GM() << " m[/td][/tr]" << endl;
	cout << "Roll Period: \t\t\t\t" << TR() << " s" << endl;
	file << "[tr][td]Roll Period: [/td][td]" << TR() << " s[/td][/tr]" << endl;

	cout << "\nBow Entrance Angle: \t\t\t" << iE() << " deg" << endl;
	file << "\n[tr][td]Bow Entrance Angle: [/td][td]" << iE() << " deg[/td][/tr]" << endl;
	cout << "Length of Engine Room: \t\t\t" << Lcm() << " m" << endl;
	file << "[tr][td]Length of Engine Room: [/td][td]" << Lcm() << " m[/td][/tr]" << endl;

	cout << setprecision(0) << "\nMain Belt: \t\t\t\t" << arm.mb_Ttop << " / " << arm.mb_Tbot << " mm at " << arm.b_deg << " degrees, " << arm.b_L << " m long with " << arm.b_H << " m above and " << arm.b_Db << " m below water" << endl;
	file << setprecision(0) << "\n[tr][td]Main Belt: [/td][td]" << arm.mb_Ttop << " / " << arm.mb_Tbot << " mm, " << arm.b_L << " m long with " << arm.b_H << " m above and " << arm.b_Db << " m below water[/td][/tr]" << endl;

	cout << "End Belt: \t\t\t\t" << arm.eb_Ttop << " / " << arm.eb_Tbot << " mm" << endl;
	file << "[tr][td]End Belt: [/td][td]" << arm.eb_Ttop << " / " << arm.eb_Tbot << " mm[/td][/tr]" << endl;

	cout << "Upper Belt: \t\t\t\t" << arm.ub_Ttop << " / " << arm.ub_Tbot << " mm, " << arm.b_uL << " m long" << endl;
	file << "[tr][td]Upper Belt: [/td][td]" << arm.ub_Ttop << " / " << arm.ub_Tbot << " mm, " << arm.b_uL << " m long[/td][/tr]" << endl;

	cout << "Main Deck: \t\t\t\t" << arm.md_T << " mm covering " << arm.md_P << "% / " << arm.md_P * v.Lpp << " m of deck" << endl;
	file << "[tr][td]Main Deck: [/td][td]" << arm.md_T << " m covering " << arm.md_P << "% / " << arm.md_P * v.Lpp << " m of deck[/td][/tr]" << endl;
	cout << "Weather Deck: \t\t\t\t" << arm.wd_T << " mm covering " << arm.wd_P << "% / " << arm.wd_P * v.Lpp << " m of deck" << endl;
	file << "[tr][td]Weather Deck: [/td][td]" << arm.wd_T << " m covering " << arm.wd_P << "% / " << arm.wd_P * v.Lpp << " m of deck[/td][/tr]" << endl;
	cout << "Splinter Deck: \t\t\t\t" << arm.sd_T << " mm covering " << arm.sd_P << "% / " << arm.sd_P * v.Lpp << " m of deck" << endl;
	file << "[tr][td]Splinter Deck: [/td][td]" << arm.sd_T << " m covering " << arm.sd_P << "% / " << arm.sd_P * v.Lpp << " m of deck[/td][/tr]" << endl;
	cout << "Ends Deck: \t\t\t\t" << arm.ed_T << " mm" << endl;
	file << "[tr][td]Ends Deck: [/td][td]" << arm.ed_T << " mm[/td][/tr]" << endl;

	cout << "Bulkhead: \t\t\t\t" << arm.blk_T << " mm in " << arm.blk_Lct << "x" << arm.blk_D << " m layers, " << arm.blk_L << " m long, " << arm.blk_H << " m tall" << endl;
	file << "[tr][td]Bulkhead: [/td][td]" << arm.blk_T << " mm in " << arm.blk_Lct << "x" << arm.blk_D << " m layers, " << arm.blk_L << " m long, " << arm.blk_H << " m tall[/td][/tr]" << endl;

	file << "[/table]" << endl;

    file.close();
}
float Ship::iE(){
	float c1 = - pow(v.Lpp / v.B, 0.80856) * pow(1 - Cw(), 0.30484) * pow(1 - Cp() - 0.0225 * lcb(), 0.6367) * pow(lr() / v.B, 0.34574) * pow(100 * Vol() / pow(v.Lpp, 3.), 0.16302);
	return 1 + 89 * exp(c1);
}
Esempio n. 10
0
float Ship::Pe(float V){
	return ( Sw()/sqrt(Vol() * v.Lpp) * pow(Vol(), 2./3.) * pow(V, 3.) /580.) * (1 + e.SA/100.);
}
Esempio n. 11
0
float Ship::Sw(){
	return 1.025 * 1.7 * v.Lpp * v.D + Vol()/v.D;
}
Esempio n. 12
0
real total_torque_cpu () {

//<USER_DEFINED>
  INPUT(Density);
  real rplanet = sqrt(Xplanet*Xplanet+Yplanet*Yplanet+Zplanet*Zplanet);
  real rsmoothing = THICKNESSSMOOTHING*ASPECTRATIO*pow(rplanet/R0,FLARINGINDEX)*rplanet;
//<\USER_DEFINED>


//<EXTERNAL>
  real* dens = Density->field_cpu;
  int pitch  = Pitch_cpu;
  int stride = Stride_cpu;
  int size_x = Nx+2*NGHX;
  int size_y = Ny+2*NGHY;
  int size_z = Nz+2*NGHZ;
  real rsm2 = rsmoothing*rsmoothing;
//<\EXTERNAL>

//<INTERNAL>
  int i;
  int j;
  int k;
  int ll;
  real dx;
  real dy;
  real dz=0.0;
  real InvDist3;
  real cellmass;
  real dist2;
  real distance;
  real fxi;
  real fyi;
  real tottorq;
  real Gtottorq;
//<\INTERNAL>

//<CONSTANT>
// real Xplanet(1);
// real Yplanet(1);
// real Zplanet(1);
// real VXplanet(1);
// real VYplanet(1);
// real VZplanet(1);
// real MplanetVirtual(1);
// real Syk(Nz+2*NGHZ);
// real InvVj(Ny+2*NGHY);
// real xmin(Nx+2*NGHX+1);
// real ymin(Ny+2*NGHY+1);
// real zmin(Nz+2*NGHZ+1);
//<\CONSTANT>

//<MAIN_LOOP>

  i = j = k = 0;
tottorq = 0;
#ifdef Z
  for (k=0; k<size_z; k++) {
#endif
#ifdef Y
    for (j=0; j<size_y; j++) {
#endif
#ifdef X
      for (i=0; i<size_x; i++ ) {
#endif
//<#>
	ll = l;
	cellmass = Vol(j,k)*dens[ll];
#ifdef CARTESIAN
	dx = xmed(i)-Xplanet;
	dy = ymed(j)-Yplanet;
#ifdef Z
	dz = zmed(k)-Zplanet;
#endif
#endif
#ifdef CYLINDRICAL
	dx = ymed(j)*cos(xmed(i))-Xplanet;
	dy = ymed(j)*sin(xmed(i))-Yplanet;
#ifdef Z
	dz = zmed(k)-Zplanet;
#endif
#endif
#ifdef SPHERICAL
	dx = ymed(j)*cos(xmed(i))*sin(zmed(k))-Xplanet;
	dy = ymed(j)*sin(xmed(i))*sin(zmed(k))-Yplanet;
#ifdef Z
	dz = ymed(j)*cos(zmed(k))-Zplanet;
#endif
#endif
	dist2 = dx*dx+dy*dy+dz*dz;
	dist2 += rsm2;
	distance = sqrt(dist2);
	InvDist3 = 1.0/(dist2*distance);
	InvDist3 *= G*cellmass;
	
	fxi  = dx*InvDist3;
	fyi  = dy*InvDist3;
	tottorq += Xplanet*fyi-Yplanet*fxi;
//<\#>
#ifdef X
      }
#endif
#ifdef Y
    }
#endif
#ifdef Z
  }
#endif
//<\MAIN_LOOP>
    

  MPI_Reduce (tottorq, Gtottorq, 1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);

  return Gtottorq;
}
Esempio n. 13
0
/**
 * construct from file name
 *
 * @param fileName file name
 */
Image3D::Image3D ( std::string fileName )
{
  vol = Vol ( fileName.c_str() );
}
Esempio n. 14
0
/**
 * construct from size given by 2 integers
 *
 * @param width width of the image
 * @param height height of the image
 * @param depth depth of the image
 */
Image3D::Image3D ( int width, int height, int depth )
{
  vol = Vol ( width, height, depth, 0 );
}