许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  adams C语言用户子程序:Adams 2013编译生成DLL超详细教程讲解.docx

adams C语言用户子程序:Adams 2013编译生成DLL超详细教程讲解.docx

阅读数 3
点赞 0
article_banner

1.操作系统: Windows xp 32 位

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

3.编译软件: Intel Visual Fortran 11.0

4.环境配置:

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

把 Fortran 安装路径,如

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

把 libifcoremd.lib 、libifcoremd.lib 、libmmd.lib 、libifportmd.lib 、libirc.lib 、svml_dispmd.lib 这 6 个库文件复制到 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 两个文件到个人工作文件夹 Adams_Matlab ,本文直接使用 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■编译操作

(1)在开始菜单下,启动Visual Studio 2010命令提示工具。

https://www.gofarlic.com\Adams_Matlab ,(3)输入指令 https://www.gofarlic.com\MSC.Software\Adams\2013\common\mdi.bat 并按回车,(2)把工作路径设置到用户子程序文件所在路径 输入指令

https://www.gofarlic.com\Adams_Matlab ,

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

於 Visual Studio 命令提



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

相关文章
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
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空