×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to write a parameter in APDL code inside workbench file ?

how to write a parameter in APDL code inside workbench file ?

how to write a parameter in APDL code inside workbench file ?

(OP)
Hello every one,
I had to write some APDL code inside harmonic analysis in workbench file.
Inside this APDL code, I applied some force to the system (f) where the value of (f) is determined from relation (f= S*A*b) where S and A are constant while (b) is parametrized in order to carry out optimization. how to deal with parameterized (b)in the APDL code given that it is dimension.
Regards

RE: how to write a parameter in APDL code inside workbench file ?

Hi,
just put a Commands (APDL) under Analysis Settings. Tick Input Arguments in Details of "Commands (APDL)", this allows you to do parametric study. Put a code into it

CODE --> APDL

S=2                      !Constant
A=3                      !Constant
b=ARG1                   !Input argument ARG1
f=S*A*b                  !Force

cmsel,s,force            !Select face from named selection named force
nsle,r                   !Select all nodes belong to the face, or you 
                         !can create a named selection with nodes and
                         !skip this nsle,r commnand

*get,ncount,node,,count  !Get number of selected nodes
*get,nnum,node,0,num,min !Get lowest index of node

fnode=f/ncount           !Force has to be divided into nodes

*do,i,1,ncount,1         !Loop over all selected nodes
 f,nnum,fy,fnode         !Apply force of magnitude fnode, in direction Y
 nnum=ndnext(nnum)       !Next node in the list
*enddo

allsel 

Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

Note that this only works for linear 1st order elements. otherwise you will apply inconsistent nodal loads using this approach.

RE: how to write a parameter in APDL code inside workbench file ?

Hi there,

Quote (petb)

you are right

To fix this, you may apply Coupling constraint or rewrite APDL code

CODE --> APDL

S=2                       !Constant
A=3                       !Constant
b=ARG1                    !Input argument ARG1
f=S*A*b                   !Force

cmsel,s,force,node        !Select all nodes belong to named selection named force

*get,ncount,node,,count   !Get number of selected nodes
*get,nnum,node,0,num,min  !Get lowest index of node

narea=0                   !Reset variable node area
*do,i,1,ncount,1          !Loop over all selected nodes
 narea=narea+arnode(nnum) !Area at node nnum apportioned from selected elements attached to node nnum
 nnum=ndnext(nnum)        !Next node in the list
*enddo                    !End loop

pressure=-f/narea         !Calculate pressure, p=F/A
sf,all,pres,pressure      !Apply surface loads on nodes 

allsel 

Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
I am so appreciated for your sincere help,
I think some misunderstanding happened.
in the workbench file , while I was preparing my problem, I checked the parameter (b) to be parametrized (i.e the mark [P] appeared in the box next to (b) value in Workbench) .
I just want to know how to mention this parameter in my APDL code and how to get some variable from APDL code to be parameter!!
Regards

RE: how to write a parameter in APDL code inside workbench file ?

Could you be more specific? Like post some pictures what you are trying to do?
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
Hi jkupka84,
Appreciated for your concern,
let me explain the problem in details as simple as I can,
I am doing maximization problem, the objective is maximize energy done by some plate due to applied force at certain frequency. the parameters are the thickness and the force . (I can parametrize both thickness and applied force in the workbench from the beginning)
I did all the model on workbench
then I added the an APDL code to define the harmonic analysis and extract potential energy as a parameter (in order to use it as objective in the optimization process which is also done using workbench tools)
there is a relation between thickness and force ( some constant let's name it E = force/thickness)
the problem for me can be figured in next points :
* when I am writing the APDL code , how I can use the force and thickness in the upper formula ? I mean what codes or symbols does the workbench give them when I parametrize them ? so I can use them in the written APDL code ?

* if the E has to not exceed some value ... so when I define it in the written APDL code, how I can make it appear as a parameter in the workbench ? ( make it in the code = ARG1 for example or what ?)
best of regards


RE: how to write a parameter in APDL code inside workbench file ?

Hi md_salem,
due the dimensionless of APDL parameters, you have to create dummy parameters with a unit value of the dimensions (mm, N, Pa, etc.). To pass the parameters to APDL you have to write Expression in Parameter Set, see the picture.



Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
well,
that means when I need to deal with some parameter (that already defined in the WORKBENCH) in the APDL code I just put its "parameter name" like (W,H, L) in the APDL code. and when I need to create a parameter in the APDL to deal with it in the WORKBENCH I give it ARG1,2,3... ?
am I right ?

RE: how to write a parameter in APDL code inside workbench file ?

This is just an example. I created a simple model of a brick, defined as WxHxL (P1xP2xP3) in SpaceClaim to be sure how to handle different parameters into APDL code.

Inputs parameter of APDL code is ARG1, ARG2,...,ARG9. You may see it in Mechanical in the Details of "Commands (APDL)". In APDL commands you just write x1=ARG1, x2=ARG2, etc.

The output parameter(s) of APDL is given by Output Search Prefix in the same Details of "Command (APDL)", my_ by default. See the picture.



Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
that is pretty good.
then, if I need to handle W or H or L in the written APDL, should I write them W , H, or L ? or P1, P2, P3 ?
Regards

RE: how to write a parameter in APDL code inside workbench file ?

If you want to use parameters from SpaceClaim, as I mentioned earlier, you have to change these parameters into dimensionless and then write in to the Expression field in the Parameters Set, please see my post above. These W, H, L are just parameters names, so it is readable for the user. Real reference name is P1, P2, etc. see the ID column.

Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
I am really appreciated for your sincere help,
I will try what did you teach me and give you a feedback
Regards

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
Dear Jiri,
your code worked perfectly for the simple example that I have given to you.
I tried to develop harder situation
I am trying to apply deflection upon the surface of block with thickness 0.15 m , both deflection and thickness are variables (parameters). the thickness is defined with parametrization of extrude process in design modular with parameter ID P28 while the deflection is initially will be 0.1mm. I suppose to calculate potential energy. Here is a part of my code

/SOLU
u=ARG9 !I put 0.1mm next to ARG9 in the table then parametrized it (put P in the check box next to it)
ANTYPE,harmonic !harmonic analysis
HROPT,full
HROUT,on
LUMP,0
CMSEL,s,block,volu
NSEL,r,loc,z,0.15 !this is the thickness of the block which I need to parametrize, its ID is P28
D,all,uz,ARG9 !I put the value of ARG9 in the table 0.1 then parametrized it (put P in the check box next to it)
ALLSEL
EQSLV,,0
PSTRES,0
HARFRQ,X11,X21 ! predefined start and end of frequencies
NUBST,20
KBC,1
DMPRAT,8E-6
SOLVE
FINISH

when I ran this code it worked properly , I received a value for the potential energy and I have saw the ARG9 as a parameter in the optimization block. but when I replaced 0.15 (in the 8th line of code) with P28 the program returned 0 as a result for potential energy . I checked the "solution information", it showed that selected location of 'z' in the case of using P28 is set to be 0 despite the original value of the thickness is already set to 0.15m. what would you think is went wrong ?
best of regards

RE: how to write a parameter in APDL code inside workbench file ?

You have to pass your thickness parameter (P28 in your case) to input parameter of APDL code. I create an example, maybe it will be more clear for you. The parameter of thickness has a dimension, you have to change it into dimensionless parameter if you want to use it in APDL code. The deflection is pass directly into APDL.



Best regards
Jiri

RE: how to write a parameter in APDL code inside workbench file ?

(OP)
well, that is look pretty good.
in that case I think I have to parametrize both P1 and P4 (in your code)
take in consideration that P1 (thickness) is extrude length.
when I tried to identify the Dummy parameter it I couldn't put a unit (the unit cell is empty and I couldn't assign it to m _

Regards

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close