|
测试了下,确实是这样,但没找到原因,估计跟DEFINE_CG_MOTION本身的调用方式有关。。建议在每个源文件下加一个DEFINE_EXECUTE_AT_END这样保证不会出歧义。#include &quot;udf.h&quot;#include<stdio.h>#define jidou2_mass 10700 //the mass of the jidou2static real jidou2_inertial[3]={83896.92,1199.83,85096.75}; //moments of inertia in 3D, here you can change the initial valuestatic real jidou2_vel_prev[3]={0,0,0};//velocity of the jidou2, here you can change the initial valuestatic real jidou2_omega_prev[3]={0,0,0};//angular velocity of the jidou2, here you can change the initial valuestatic real jidou2_dis_prev[3]={0,0,0};//displacement of the jidou2, here you can change the initial valuestatic real jidou2_theta_prev[3]={0,0,0};//angular displacement of the jidou2, here you can change the initial valuestatic real jidou2_acc[3]={0,0,0};static real jidou2_rotacc[3]={0,0,0};static real jidou2_centroid[3]={0.58,4.85,0}; //centroid of the jidou2, here you can change the initia]valueint i=1;DEFINE_EXECUTE_AT_END(at_end){ real time; FILE *fp2; FILE *fp1; time = RP_Get_Real(&quot;flow-time&quot;); fp2=fopen(&quot;ca1&quot;,&quot;a&quot;); fp1=fopen(&quot;count0&quot;,&quot;a&quot;); fprintf(fp2,&quot;%.6e %.8f %.8f %.8f %.8f %.8f %.8f
&quot;,time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]); fprintf(fp1,&quot;%.6e%6i
&quot;,time,i); i=i+1; Message(&quot;this is the firt time
&quot;); fclose(fp2); fclose(fp1); }DEFINE_CG_MOTION(JiDou2,dt,vel,omega,time,dtime){ Thread *tread; Domain *domin; face_t f; real force[3];//the total force on the jidou2. real moment[3];//the total momentum on the jidou2 real d_vel[3]; real d_omega[3]; real jidou2_k1; real jidou2_k2; real h=4.85; //h定义为箕斗高度的一半 real L=440; //暂取井道深度m real jidou2_s=0; // jidou2_s定义为箕斗的提升行程 real s20=195.75; // s20定义为t=0时箕斗距罐道绳顶部的距离, s10=220-19.4-4.85=195.75 real n2=4; // n2定义为箕斗两侧罐道绳的数量 real Q=5650; // Q为每根罐道绳底部张紧重锤的质量; real q=8.94; // q为罐道绳单位长度的重量,Φ查标准YB/T 5295-2006密封钢丝绳表 real g=9.81; // g为重力加速度; FILE *fp2; FILE *fp1; fp2=fopen(&quot;ca3&quot;,&quot;a&quot;); fp1=fopen(&quot;count1&quot;,&quot;a&quot;); fprintf(fp2,&quot;%.6e %.8f %.8f %.8f %.8f %.8f %.8f
&quot;,time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]); fprintf(fp1,&quot;%.6e%6i
&quot;,time,i); i=i+1; Message(&quot;this is the firt time
&quot;); fclose(fp2); fclose(fp1); tread=DT_THREAD(dt); //get the thread pointer for which this motion is defined domin=THREAD_DOMAIN(tread); //DT_THREAD(t): pointer to face thread; Compute_Force_And_Moment(domin,tread,jidou2_centroid,force,moment,FALSE); //the macro for the calculation of total force and total momentum on the jidou2.if(time<=1.0) { vel[1]=-time*9.7; jidou2_s=-vel[1]*time/2; } else { vel[1]=-9.7; jidou2_s=-vel[1]*time-9.7/2; } jidou2_k1=(n2*Q*g+n2*q*(L-s20-jidou2_s+h)*g+ jidou2_mass*g)/(s20+jidou2_s-h); jidou2_k2=(n2*Q*g+n2*q*(L-s20-jidou2_s-h)*g)/(L-s20-jidou2_s-h); jidou2_dis_prev[0]=jidou2_dis_prev[0]+jidou2_vel_prev[0]*dtime; jidou2_theta_prev[2]=jidou2_theta_prev[2]+jidou2_omega_prev[2]*dtime; jidou2_acc[0]=(force[0]-jidou2_k1*(jidou2_dis_prev[0]-h*jidou2_theta_prev[2])-jidou2_k2*(jidou2_dis_prev[0]+h*jidou2_theta_prev[2]))/jidou2_mass; d_vel[0]=jidou2_acc[0]*dtime; //get the accelaration of the jidou2 with Newton’s second 1aw. jidou2_vel_prev[0]=jidou2_vel_prev[0]+d_vel[0];//v+dv get the new translational velocity vel[0]=jidou2_vel_prev[0]; jidou2_rotacc[2]=(moment[2]+jidou2_k1*(jidou2_dis_prev[0]-h* jidou2_theta_prev[2])*h-jidou2_k2*(jidou2_dis_prev[0]+h*jidou2_theta_prev[2])*h)/jidou2_inertial[2]; d_omega[2]=jidou2_rotacc[2]*dtime; //get the accelaration of the jidou2 with Newton’s second law. jidou2_omega_prev[2]=jidou2_omega_prev[2]+d_omega[2];//ω+dωget the new rotational velocity omega[2]=jidou2_omega_prev[2]; Message(&quot;%.6e %.8f %.8f %.8f %.8f %.8f %.8f
&quot;,time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]);} |
|
共 3 个关于本帖的回复 最后回复于 2013-7-8 18:27