|
/*-----------------------------------------
Description:
力矩分配法校中轴系。只是作分配用。
Environment:VC6.0
Date:10:21 2008-1-9
Email:eryar@163.com
-----------------------------------------*/
#include <math.h>
#include <conio.h>
#include <stdio.h>
#define MAX 100
/*--------函数声明------------------*/
void print(int N,float B[]);
void distribution(float B1[],float L[],int N);
void transmission(float B1[],int N);
/*----------------------------------*/
main()
{
int i,j,k;
int TIMES=0; /*Frequence of Distribution*/
int NODE=0; /*The number of Node*/
float FT1[MAX]; /*Save Fixed Torque*/
float FT2[MAX]; /*Total Fixed Torque*/
float Lambda[MAX]; /*Distribution ratio*/
FILE *eryar; /*Save to the file*/
/*输入数据*/
printf("节点数:"); scanf("%d",&NODE);
printf("分配次数:"); scanf("%d",&TIMES);
printf("---分配系数---\n");
for(i=0;i<(NODE*2-2);i++) {
printf("Lambda %d:",i+1);
scanf("%f",&Lambda);
}
printf("---固定弯矩---\n");
for(i=0;i<(NODE*2-2);i++) {
printf("Torque %d:",i+1);
scanf("%f",&FT1);
FT2=FT1;
}/*输入数据*/
k=NODE*2-2;
eryar = fopen("axis.txt","w"); /*打开文件*/
fprintf(eryar,"\t\t---轴系合理校中---\n");
for(i=0;i<k;i++) fprintf(eryar,"%.2f\t",Lambda);
fprintf(eryar,"\n");
for(i=0;i<k;i++)
fprintf(eryar,"%.2f\t",FT1);
fprintf(eryar,"\n");
print(NODE,FT1); printf("\n");
/*分配传递*/
for(i=0;i<TIMES;i++) {
distribution(FT1,Lambda,NODE);
for(j=0;j<k;j++) FT2[j]+=FT1[j];
print(NODE,FT1); printf("\n");
for(j=0;j<k;j++) fprintf(eryar,"%.2f\t",FT1[j]);
fprintf(eryar,"\n");
transmission(FT1,NODE);
for(j=0;j<k;j++) FT2[j]+=FT1[j];
print(NODE,FT1); printf("\n");
for(j=0;j<k;j++) fprintf(eryar,"%.2f\t",FT1[j]);
fprintf(eryar,"\n");
}/*分配传递*/
print(NODE,FT2);
printf("\007");
for(j=0;j<k;j++) fprintf(eryar,"%.2f\t",FT2[j]);
fprintf(eryar,"\n*注:最后一行为总弯矩!");
fprintf(eryar,"\n\t\t---eryar@163.com---\n");
fclose(eryar);/*关闭文件*/
printf("\nPress any key to halt...");
getch();
}
/*力矩分配*/
void distribution(float B1[],float L[],int N)
{
int i;
int last;
float SUM[MAX];
last = N*2-3;
B1[0] = B1[0] * L[0];
B1[0] = -B1[0];
B1[last] = B1[last]*L[last];
B1[last] = -B1[last];
for(i=0;i<last-2;i+=2) {
SUM = B1[i+1]+B1[i+2]; /*每个节点之和*/
SUM = -SUM; /*力矩取 负号*/
B1[i+1] = SUM*L[i+1]; /*按各节点的 */
B1[i+2] = SUM*L[i+2]; /*分配系数分配*/
}
}/*力矩分配*/
/*力矩按0.5传递*/
void transmission(float B1[],int N)
{
int i;
int last;
float temp[MAX];
last = N*2-3;
for(i=0;i<=last;i++)
temp = B1;
for(i=0;i<=last;i+=2) {
B1 = temp[i+1]/2;
B1[i+1] = temp/2;
}
}/*力矩传递*/
void print(int N,float B[])
{
int i;
for(i=0;i<N*2-2;i++)
printf("%.2f\t",B);
} |
评分
-
查看全部评分
|