xifengyang 发表于 2015-5-18 22:16:27

机械系统动力学分析及ADAMS应用教程中的例子—求助

本帖最后由 xifengyang 于 2015-5-18 22:18 编辑

最近在编写子程序,尝试把 《机械系统动力学分析及ADAMS应用教程》中的例子做了一下。仿真时发现小球不是沿着斜面运动而是做匀速线下的直线的运动(很缓慢)。希望能与大家交流交流,多多指教~~希望把这个例子真正做通,给大家一个参照。
一下是程序
#include "slv_c_utils.h"
/*
*Using a function typedef from slv_c_utils.h, please declare your
*user subroutine before defining it.This will allow a compiler to
*perform type checking for your subroutine arguments.
*/
   
adams_c_Gfosub    Gfosub;
/*
*Define a subroutine named 'Gfosub'.Any name is allowed,
*as long as it is mixed case and the name is specified in
*the ADAMS input file using the ROUTINE= keyword.
*
*Adams distinguishes between FORTRAN and C subroutines by looking
*up the function name in the library.If it finds a mixed case
*name then it assumes that the function is a C function.Otherwise
*it assumes Fortran.
*/
void Gfosub(const struct sAdamsGforce* gfo, double time, int dflag, int iflag, double* result)
{
double ct =      gfo->PAR;
double cr =      gfo->PAR;
int    im = (int)gfo->PAR;
int    jm = (int)gfo->PAR;
double vel;
int    ipar;
int    nstates;
int    errflg;

/*
      Call SYSARY to collect information for the
      calculations below. Note: if IFLAG is true, this
      call is actually setting functional dependencies.

--- Use VEL to get marker translational and rotational
      velocities
*/
ipar = im;
ipar = jm;
ipar = jm;
c_sysary("VEL", ipar, 3, vel, &nstates, &errflg);
/*
--- Check SYSARY call through ERRMES utility routine
*/
c_errmes(errflg,"Error calling SYSARY for VEL", gfo->ID, "STOP");
/*
--- Evaluate GFORCE components -------------------------
*/
result = -ct*vel;
result = -ct*vel;
result = -ct*vel;
result = -cr*vel;
result = -cr*vel;
result = -cr*vel;
}

xifengyang 发表于 2015-5-18 22:19:59

C:\Users\Administrator\Desktop\lizi—jiaocai\仿真结果.jpg

xifengyang 发表于 2015-5-18 22:24:06


仿真结果图:。

小球一直向下运动。
页: [1]
查看完整版本: 机械系统动力学分析及ADAMS应用教程中的例子—求助