設(shè)計(jì)仿真 | Adams線性化分析子程序應(yīng)用
本文主要說(shuō)明Adams 2022.1版本新增的、關(guān)于子程序中的c_get_linear_mat_states功能函數(shù)的綜合應(yīng)用。對(duì)于多體動(dòng)力學(xué)中的線性化分析,其實(shí)是非常重要的一塊內(nèi)容,尤其在獲取系統(tǒng)頻率特性與控制系統(tǒng)耦合時(shí)非常有用,為此,在新版Adams中,提供了專門的c_get_mat_states函數(shù),方便高級(jí)用戶在調(diào)用CONSUB子程序時(shí)進(jìn)行關(guān)聯(lián)調(diào)用實(shí)現(xiàn)更為靈活高效的使用。
多體系統(tǒng)的線性化分析
Adams的線性化分析功能,在一般的應(yīng)用中主要有四種形式:
?Linear/eigensol,獲取系統(tǒng)本征解,研究系統(tǒng)穩(wěn)定性,基于復(fù)平面工具針對(duì)實(shí)部與虛部的落點(diǎn)進(jìn)行具體研究;
?Linear/statemat,獲取系統(tǒng)對(duì)應(yīng)的狀態(tài)空間矩陣,是一種標(biāo)準(zhǔn)形式;
?Linear/mkb,獲取系統(tǒng)對(duì)應(yīng)的狀態(tài)空間矩陣,是一種Nastran對(duì)應(yīng)的形式;
?Linear/export,獲取Nastran對(duì)應(yīng)格式的輸入文件,比如BDF;
上圖針對(duì)一個(gè)自由度的彈簧振子系統(tǒng),進(jìn)行線性化分析獲得系統(tǒng)的特征頻率以及復(fù)平面對(duì)應(yīng)數(shù)據(jù),當(dāng)然也可以獲得對(duì)應(yīng)的模態(tài)振型動(dòng)畫形式。這里采用的是linear/eigensol命令實(shí)現(xiàn)的求解,而該命令還可以同初始化、靜平衡、運(yùn)動(dòng)學(xué)、動(dòng)力學(xué)相關(guān)的命令結(jié)合起來(lái)操作,可以對(duì)系統(tǒng)任意狀態(tài)點(diǎn)進(jìn)行模型的線性化處理。
線性化分析子程序功能
新版添加的c_get_linear_mat_states函數(shù),可以使得工程師進(jìn)行更加方便的用戶子程序綜合應(yīng)用。之前,為了獲取系統(tǒng)的狀態(tài)空間矩陣,比如標(biāo)準(zhǔn)的ABCD矩陣形式,只能通過(guò)Linear/statemat命令實(shí)現(xiàn),沒有其它的功能可以獲取該類數(shù)據(jù)。因此,當(dāng)工程師需要在自己編寫的用戶子程序進(jìn)行狀態(tài)空間矩陣數(shù)據(jù)調(diào)用時(shí),只能通過(guò)先將這些數(shù)據(jù)求解并存儲(chǔ)于指定文件中,然后再通過(guò)編程讀取這些數(shù)據(jù),非常的不方便。
有了c_get_linear_mat_states功能后,工程師可以通過(guò)子程序CONSUB進(jìn)行狀態(tài)空間矩陣的求解后,直接進(jìn)行其數(shù)據(jù)的調(diào)用,也就是狀態(tài)空間矩陣求解以及狀態(tài)向量獲取可以直接在用戶子程序中完成,不再需要額外的輸入輸出工作。
上圖仍舊是單自由度彈簧振子模型,只不過(guò)在本模型中,剛度和阻尼會(huì)隨時(shí)間變化,并且將會(huì)在0s,1s,5s通過(guò)子程序CONSUB分別對(duì)系統(tǒng)進(jìn)行線性化處理,當(dāng)然在子程序中有c_get_linear_mat_states函數(shù)的調(diào)用。另外,模型上施加的外部載荷、彈簧力都是通過(guò)Gforce實(shí)現(xiàn)的,通過(guò)函數(shù)的綜合應(yīng)用實(shí)現(xiàn)更靈活的設(shè)置。
為了實(shí)現(xiàn)上述所要求的仿真工況,必須借助腳本命令來(lái)完成,在初始階段首先對(duì)模型進(jìn)行初始化求解,接著完成靜平衡計(jì)算,然后才進(jìn)行第一次線性化求解,進(jìn)而進(jìn)行動(dòng)態(tài)求解,在1秒完成時(shí),進(jìn)行第二次線性化求解,以此類推。仿真腳本命令如下所示:
上圖分別為變化的剛度和阻尼參數(shù)。
下面著重對(duì)CONSUB及c_get_linear_mat_states函數(shù)進(jìn)行說(shuō)明。需要注意該函數(shù)只能基于C使用,F(xiàn)ortran不支持。
#include
#include
#include "slv_c_utils.h"
#include
adams_c_Consub Consub;
void printVec(FILE *fp, double *vec, int nrow, int ncol) {
if (vec)
{
int nele = nrow * ncol;
int i;
for (i = 0; i < nele; i++) {
fprintf(fp, "%25.17e", vec[i]);
if ((i+1)%3 == 0)
{
fprintf(fp, "\n");
}
}
fprintf(fp, "\n");
}
else
{
fprintf(fp, "There is no matrix generated!\n");
}
}
void printInfo(FILE *fp, struct sAdamsLinearDataOut *out, int rm, char *msg)
{
fprintf(fp, "%s\n", msg);
fprintf(fp, "Number of differential states ND = %d, Number of kinematic states NK = %d\n", out->ND, out->NK);
fprintf(fp, "A matrix, nrow = %5d, ncol = %5d->\n", out->NS, out->NS);
printVec(fp, out->A, out->NS, out->NS);
fprintf(fp, "B matrix, nrow = %5d, ncol = %5d->\n", out->NS, out->NI);
printVec(fp, out->B, out->NS, out->NI);
fprintf(fp, "C matrix, nrow = %5d, ncol = %5d->\n", out->NO, out->NS);
printVec(fp, out->C, out->NO, out->NS);
fprintf(fp, "D matrix, nrow = %5d, ncol = %5d->\n", out->NO, out->NI);
printVec(fp, out->D, out->NO, out->NI);
if (rm)
{
fprintf(fp, "State vector, nrow = %5d, ncol=%5d->\n", 3, out->NS + 1);
printVec(fp, out->STATESINFO, out->NS + 1, 3);
}
else
{
fprintf(fp, "State vector, nrow = %5d, ncol=%5d->\n", 3, out->NS);
printVec(fp, out->STATESINFO, out->NS, 3);
}
fprintf(fp, "Values of the state vector->\n");
printVec(fp, out->STATES, out->NS, 1);
}
void Consub(const struct sAdamsControl* con)
{
int errflg=1;
int id=0;
int npar;
int par[8];
int type;
int i;
npar = con->NPAR;
for (i = 0; i < npar; i++)
{
par[i] = (int)con->PAR[i];
}
if (npar == 6)
{
par[6] = 0;
}
struct sAdamsLinearDataIn dataIn;
dataIn.PINPUT = par[0];
dataIn.POUTPUT = par[1];
dataIn.PSTATE = par[2];
dataIn.RM = par[3];
dataIn.NODAMPIN = par[4];
dataIn.ORIGINAL = par[5];
dataIn.USEPBCS = par[6];
FILE *fp;
char fileName[40] = "linear_utility_res";
char num[] = {par[7] + '0', '\0'};
strcat(fileName, num);
fp = fopen(fileName, "w");
struct sAdamsLinearDataOut out;
type = 1;
c_get_linear_mat_states(&dataIn, &out, &type);
type = 0;
c_get_linear_mat_states(&dataIn, &out, &type);
printInfo(fp, &out, dataIn.RM, "Evaluation stage");
type = 5;
c_get_linear_mat_states(&dataIn, &out, &type);
fclose(fp);
c_usrmes(errflg, "\n\nCalled from consub.\n\n", id, "INFO_NOPAD");
}
上述代碼中核心是Consub程序,另外的兩個(gè)print函數(shù)只是為了輸出結(jié)果到文件中。可以看到在Consub中,c_get_linear_mat_states函數(shù)的使用就像其它獲取狀態(tài)變量的函數(shù)一樣非常方便。Par[]對(duì)應(yīng)了Consub的8個(gè)輸入?yún)?shù),前面的7個(gè)輸入?yún)?shù)傳輸給dataIn結(jié)構(gòu)體,而c_get_linear_mat_states()的基本形式如下所示:
void c_get_linear_mat_states(struct sAdamsLinearDataIn *dataIn, struct sAdamsLinearDataOut *dataOut, int *type);
具體的dataIn和dataOut所包含的具體內(nèi)容可以在幫助中查看。
另外,需要注意,當(dāng)一個(gè)Consub中有多次該函數(shù)的調(diào)用,只需要一次初始化和一次內(nèi)存清理,而c_get_linear_mat_states()只能在Consub子程序中調(diào)用。
下面為第一次的輸出結(jié)果:
Evaluation stage
Number of differential states ND = 0, Number of kinematic states NK = 2
A matrix, nrow = 2, ncol = 2->
-4.00000000000000022e-01 1.00000000000000000e+00
-4.00000000000000000e+02 0.00000000000000000e+00
B matrix, nrow = 2, ncol = 1->
4.00000000000000000e+01 0.00000000000000000e+00
C matrix, nrow = 1, ncol = 2->
-4.00000000000000022e-01 -4.00000000000000000e+02
D matrix, nrow = 1, ncol = 1->
4.00000000000000000e+01
State vector, nrow = 3, ncol= 2->
1.00000000000000000e+00 2.00000000000000000e+00
8.00000000000000000e+00 1.00000000000000000e+00
2.00000000000000000e+00 2.00000000000000000e+00
Values of the state vector->
0.00000000000000000e+00 4.00000000000000000e+02
總結(jié)
Adams新版提供的c_get_linear_mat_states()函數(shù)可方便地獲得狀態(tài)空間矩陣及狀態(tài)矢量,方便Consub程序的綜合應(yīng)用,極大拓展了多體線性化仿真以及同其它應(yīng)用的結(jié)合,方便完成更高級(jí)、更復(fù)雜的工程分析。
文件路徑為E:\MSC.Software\Adams\2022_1_875404\solver\samples
Linear_utility.acf, Linear_utility.adm,Linear_utility.c(c碼轉(zhuǎn)化為dll需要參考Adams用戶子程序一般流程,需要相關(guān)編譯環(huán)境支持)。
文章來(lái)源:海克斯康工業(yè)軟件
工程師必備
- 項(xiàng)目客服
- 培訓(xùn)客服
- 平臺(tái)客服
TOP




















