Bill Bulat
Ansys Employee
Hello,If you create a command object containing the following APDL code you can specify the amplitude, frequency, number of points per cycle, and total duration (measured in number of cycles) in the ARG1, ARG2, ARG3, and ARG4 fields of Details respectively. The code creates a table array named harmtrns. You can then add whatever line you like to apply the harmonically varying using tabular loading, e.g.,d,sig,volt,%harmtrns%nnnC*** MACRO harmtrns.mac PRODUCESnC*** SINE WAVE LOAD FOR TRANSIENTnC*** ANALYSESnnC*** BILL BULAT 05/31/2005nC*** MODIFIED 09/12/2012nnC*************************************************************************nC*** INPUT PARAMETERS (EDIT TO SUIT)nC*************************************************************************nampltd=arg1tt! AMPLITUDE OF LOADnfrq=arg2tt! OPERATING FREQUENCY (HZ)nnpts_cy=arg3tt! # OF PTS/CYCLEnncy=arg4tt! # OF CYCLES (DURATION OF TRANSIENT)nnnC*************************************************************************nC*** DERIVED PARAMETERSnC*************************************************************************nnpts=npts_cy*ncy   ! TOTAL # OF PTSndt=(1/frq)/npts_cy  ! TIME STEP SIZEnP=1/frq        ! PERIOD (s)n*afun,radnpi=acos(-1)nnnC*************************************************************************nC*** DIMENSION ARRAYnC*************************************************************************n*del,harmtrnsn*dim,harmtrns,table,npts+1,,,timennnC*************************************************************************nC*** FILL ARRAYnC*************************************************************************nn*do,i,1,npts+1tt! FILL THE DATA COLUMN (ALWAYS DO THIS FIRST)n tm=(i-1)*dtn harmtrns(i,1)=ampltd*sin((2*pi/P)*tm)n*enddonn*do,i,1,npts+1tt! FILL THE TIME VALUE COLUMN (COLUMN 0)n tm=(i-1)*dtn harmtrns(i,0)=tmn*enddonn*vplo,harmtrns(1,0),harmtrns(1,1)n