1.耐压舱强度校核控制台程序代码。也就是把书的公式整理一下写成代码,大家可能找公式比较费劲。
2.这个程序是读文件和写文件的。对于优化耐压舱厚度的算例,可以把厚度设成循环变量改进一下。
3.输入和输出的txt:
Indata.txt
0.35
840
115000
1000
0.01
1.5
200
100
135
4
800
20
10
// RinCabin.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
#include
#include
using namespace std;
void RunRib()
{
int i=0;
//中间变量
double u=0,B=0,r=0,u1=0,u2=0,F[5]={0},K[5]={0},Qe1=0,Qe2=0,Cs1=0,Cs2=0,bili1=0,bili2=0;
//输入输出变量
//材料属性泊松比0,屈服极限1,弹性模量2
//环境变量水深3、单位水深压强4,安全系数5
//RibCabin肋骨面积6,肋骨间距l7,舱段半径R8,舱段厚度t9,舱长L10,肋骨高度h11,肋骨宽度b12
double In[15]={0};
//输出变量Q10,Q21,Qf2,Pcr13,Pcr24,Pe15,Pe26
double Out[15]={0};
double Pj=0;
ifstream fin("Indata.txt",ios::in);
ofstream fout("Outdata.txt",ios::app);
fstream fileemp("Outdata.txt",ios::out);
if(!fin){
cout<<"This Inputdata is not exist!\n"<>In[i];
i++;
}
//计算部分
Pj=In[3]*In[4]*In[5];
u=0.5*pow(3*(1-pow(In[0],2)),0.25)*(In[7]/pow(In[9]*In[8],0.5));
r=0.5*pow(3*(1-pow(In[0],2)),0.5)*(Pj*pow(In[8],2)/(In[2]*pow(In[9],2)));
B=In[7]*In[9]/In[6];
u1=u*pow(1-r,0.5);
u2=u*pow(1+r,0.5);
F[4]=u2*sinh(2*u1)+u1*sin(2*u2);
F[0]=pow(1-pow(r,2),0.5)/((cosh(2*u1)-cos(2*u2))/F[4]);
F[1]=(3*(1-0.5*In[0])*(u2*sinh(2*u1)-u1*sin(2*u2))/pow(3*(1-pow(In[0],2)),0.5))/F[4];
F[2]=(6*(1-0.5*In[0])*(u1*cosh(u1)*sin(u2)-u2*sinh(u1)*cos(u2))/pow(3*(1-pow(In[0],2)),0.5))/F[4];
F[3]=2*(1-0.5*In[0])*(u1*cosh(u1)*sin(u2)-u2*sinh(u1)*cos(u2))/F[4];
//强度校核
//求Q1
K[0]=1-F[3]/(1+B*F[0]);
Out[0]=K[0]*Pj*In[8]/In[9];
if(Out[0]<0.85*In[1]){
cout<<"轴向应力满足\n"<>num;
while(num){
switch(num){
case 1:
RunRib();//本来想要集成设计好几个功能,最后弄了一个功能。。。
break;
default:
break;
}
cout<<"If you want to exit,please input 0!\n"<>num;
}
return 0;
}