许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  四阶Adams显式方法C语言程序及Adams 2013编译用户子程序.doc

四阶Adams显式方法C语言程序及Adams 2013编译用户子程序.doc

阅读数 4
点赞 0
article_banner

Adams2013编译C语言用户子程序

1.操作系统:Windows xp 32位

2.软件版本:Adams 2013 32位、Visual Studio 2010专业版 32位

3.编译软件:Intel Visual Fortran 11.0

4.环境配置:

1) 在操作系统环境变量Path中增加Adams启动文件mdi.bat的路径,如https://www.gofarlic.com\MSC.Software\Adams\2013\common\mdi.bat

2) 把Fortran安装路径,如

https://www.gofarlic.com\IVF2011\Intel\ComposerXE-2011\compiler\lib\ia32

https://www.gofarlic.com\IVF2011\Intel\ComposerXE-2011\compiler\lib\ia32,把libifcore.liblibifcoremd.lib、libmmd.lib、libifportmd.lib、libirc.lib、svml_dispmd.lib这个库文件复制到Adams安装路径下win32文件夹下

5.编写用户子程序

Adams安装程序https://www.gofarlic.com\MSC.Software\Adams\2013\solver\c_usersubs文件夹下有C语言编写的常用的用户子程序,其中slv_c_utils.h文件是用户子程序的头文件。编写用户子程序时,在这些程序的基础上进行更改会有事半功倍的效果。

本文以编写VForce用户子程序为例,对其编写、编译操作过程进行说明。

复制vfosub.c和slv_c_utils.h两个文件到个人工作文件夹本文直接使用vfosub.c的原始代码,其代码为:

#include "slv_c_utils.h"

adams_c_Vfosub Vfosub;

/*

* Note:

* Use mixed case names for the Adams subroutine names when using the C

* style interface. For the default subroutine name capitalize the first

* letter and have the remaining letters lower case; Gfosub for example.

* Doing this insures that Adams Solver correctly distinguishes a C style

* subroutine from Fortran and calls with the appropriate interface.

*

*/

void Vfosub(const struct sAdamsVforce* vfo, double time, int dflag, int iflag, double* result)

{

/* Assign readable variable names to passed parameters */

double c=vfo->PAR[0];

int ipar[3]={(int)vfo->PAR[1], (int)vfo->PAR[2],(int)vfo->PAR[1]};

/* Local variables */

double vel[3];

int nstates;

int errflg;

/* call SYSARY for translation velocities TVEL */

c_sysary("TVEL", ipar, 3, vel, &nstates, &errflg);

c_errmes(errflg, "Error calling SYSARY for TVEL", vfo->ID, "STOP");

/* --- Evaluate VFORCE components ------------------------- */

result[0] = -c * vel[0];

result[2] = -c * vel[1];

result[2] = -c * vel[2];

}

注意:因为代码中引用了slv_c_utils.h,复制时必须同时复制slv_c_utils.h文件,否则编译时会报错。

6.编译操作

在开始菜单下,启动Visual Studio 20命令提示工具。

把工作路径设置到用户子程序文件所在路径https://www.gofarlic.com\

输入指令cd https://www.gofarlic.com\Adams_Matlab并按回车。

(3) 输入https://www.gofarlic.com\MSC.Software\Adams\2013\common\mdi.bat并按回车,

系统进入Adams环境中


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空