XANSYS Forum Index
    Register    

FAQ    Search    Memberlist    Usergroups    SmartFeedSmartFeed    Profile    Log in
[Xansys] Add scalar parameters
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    XANSYS Forum Index -> XANSYS
Author Message
nicolas.bouillon
User


Joined: 08 Apr 2014
Posts: 14

PostPosted: Tue Jul 08, 2014 3:10 am  Reply with quote

Dear all,

Is it possible to select scalar parameters and to add them (thanks to a APDL macro) ?

For example :


Scalar parameters :

COUNT = 1
I = 25
J = 25
K = 25
L1 = 73.5
L2 = 105
L3 = 54.5
L12 = 20


I would like select " L1,L2,L3,L12 " and add them : Ltotal = 73.5+105+54.5+20 = 253

Regards,

Nicolas BOUILLON
Apprentice structural engineer
SAIPEM SA
SAINT QUENTIN EN YVELINES - FRANCE
******************************************************************************************
CONFIDENTIALITY NOTICE
This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from your system.
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
Martin Liddle
User


Joined: 15 Aug 2008
Posts: 1274
Location: Chesterfield, UK

PostPosted: Tue Jul 08, 2014 3:37 am  Reply with quote

On 08/07/2014 10:35, BOUILLON Nicolas wrote:
Quote:

Is it possible to select scalar parameters and to add them (thanks to a APDL macro) ?

I don't know how to do exactly what you are asking. However if you know
which parameters to select then why are you unable to form an arithmetic
expression (L1+L2+L3) to get the value you require?

--
Martin Liddle, Tynemouth Computer Services,
Chesterfield, Derbyshire, UK.
www.tynecomp.co.uk
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
_________________
Martin Liddle, Tynemouth Computer Services,
Chesterfield, UK.
Back to top
View user's profile Send private message Visit poster's website
jose.galan
User


Joined: 21 Oct 2008
Posts: 140

PostPosted: Tue Jul 08, 2014 4:12 am  Reply with quote

Dear Mr. Bouillon,

you may also consider storing the parameters in an array.

*dim,lvec,array,12

lvec(1)=73.5,105,54.5

lvec(12)=20

If you want to sum some some elements of the array, you can do it like
this:

lres=lvec(1)+lvec(2)+lvec(3)+lvec(12)

This is similar to what Mr. Liddle pointed out in his post.

You can also define an array of the indices that you want to sum, and
then do a loop over the indices and sum the component.

You could alternatively define a masking array of the same length as
lvec, with ones in the positions that you want to add and zeros
elsewhere. Then use the commands *vmask to use that masking array, and
finally use the *vscfun to sum the masked values of your lvec array:

*vmask,maskingarray

*vfun,lres,sum,lvec

Best regards,

Jose M. Galan

Constr. Eng. Dept.

Univ. Sevilla

Spain

El 08/07/2014 12:37, Martin Liddle escribió:

Quote:
On 08/07/2014 10:35, BOUILLON Nicolas wrote:

Quote:
Is it possible to select scalar parameters and to add them (thanks to a APDL macro) ?

I don't know how to do exactly what you are asking. However if you know
which parameters to select then why are you unable to form an arithmetic
expression (L1+L2+L3) to get the value you require?

+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
nicolas.bouillon
User


Joined: 08 Apr 2014
Posts: 14

PostPosted: Tue Jul 08, 2014 4:45 am  Reply with quote

Thanks a lot for your answers !

The problem is that I have 200 parameters to add and it will be desirable to have a macro which select parameters that i want (for example : L%i% with i =1,2,3,...)...

Regards,

Nicolas BOUILLON
Apprentice structural engineer
SAIPEM SA
SAINT QUENTIN EN YVELINES - FRANCE

-----Message d'origine-----
De : Xansys [mailto:xansys-bounces@xansys.org] De la part de Martin Liddle
Envoyé : mardi 8 juillet 2014 12:37
À : xansys@xansys.org
Objet : Re: [Xansys] Add scalar parameters

On 08/07/2014 10:35, BOUILLON Nicolas wrote:
Quote:

Is it possible to select scalar parameters and to add them (thanks to a APDL macro) ?

I don't know how to do exactly what you are asking. However if you know which parameters to select then why are you unable to form an arithmetic expression (L1+L2+L3) to get the value you require?

--
Martin Liddle, Tynemouth Computer Services, Chesterfield, Derbyshire, UK.
www.tynecomp.co.uk
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+
******************************************************************************************
CONFIDENTIALITY NOTICE
This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from your system.
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
Martin Liddle
User


Joined: 15 Aug 2008
Posts: 1274
Location: Chesterfield, UK

PostPosted: Tue Jul 08, 2014 4:51 am  Reply with quote

On 08/07/2014 12:23, BOUILLON Nicolas wrote:

Quote:
The problem is that I have 200 parameters to add and it will be desirable to have a macro which select parameters that i want (for example : L%i% with i =1,2,3,...)...

I think you need to use an array rather than lots of scalar parameters
then you can use *VSCFUN,ParR,SUM,ArrayName


--
Martin Liddle, Tynemouth Computer Services,
Chesterfield, Derbyshire, UK.
www.tynecomp.co.uk
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
_________________
Martin Liddle, Tynemouth Computer Services,
Chesterfield, UK.
Back to top
View user's profile Send private message Visit poster's website
joseph.metrisin
User


Joined: 07 May 2009
Posts: 404

PostPosted: Tue Jul 08, 2014 5:11 am  Reply with quote

Your question isn't real clear. How are these parameters being defined. What is your selection criteria?



Joseph T Metrisin
Structures Lead
Florida Turbine Technologies, Inc
1701 Military Tr. Suite 110
Jupiter, FL 33458 U.S.A.
+1 (561)427-6346 Office

(561)427-6191 Fax
JMetrisin@fttinc.com

Visit our website: www.fttinc.com

FTT's public email encryption keys are stored on the FTT Verified Directory at http://keys.fttinc.com

-----------------------------------------------------------------------------------------------------
Confidentiality Note:
The information contained in this transmission and any attachments are proprietary and may be privileged, intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you received this communication in error, please delete the message and immediately notify the sender via the contact information listed above.
-----------------------------------------------------------------------------------------------------


-----Original Message-----
From: Xansys [mailto:xansys-bounces@xansys.org] On Behalf Of BOUILLON Nicolas
Sent: Tuesday, July 08, 2014 7:24 AM
To: ANSYS User Discussion List
Subject: [FTT_SPAM] - Re: [Xansys] Add scalar parameters

Thanks a lot for your answers !

The problem is that I have 200 parameters to add and it will be desirable to have a macro which select parameters that i want (for example : L%i% with i =1,2,3,...)...

Regards,

Nicolas BOUILLON
Apprentice structural engineer
SAIPEM SA
SAINT QUENTIN EN YVELINES - FRANCE

-----Message d'origine-----
De : Xansys [mailto:xansys-bounces@xansys.org] De la part de Martin Liddle Envoyé : mardi 8 juillet 2014 12:37 À : xansys@xansys.org Objet : Re: [Xansys] Add scalar parameters

On 08/07/2014 10:35, BOUILLON Nicolas wrote:
Quote:

Is it possible to select scalar parameters and to add them (thanks to a APDL macro) ?

I don't know how to do exactly what you are asking. However if you know which parameters to select then why are you unable to form an arithmetic expression (L1+L2+L3) to get the value you require?

--
Martin Liddle, Tynemouth Computer Services, Chesterfield, Derbyshire, UK.
www.tynecomp.co.uk
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+
******************************************************************************************
CONFIDENTIALITY NOTICE
This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from your system.
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
christopher.wright
User


Joined: 17 Jun 2009
Posts: 927

PostPosted: Tue Jul 08, 2014 10:44 am  Reply with quote

On Jul 8, 2014, at 4:35 AM, BOUILLON Nicolas wrote:

Quote:
I would like select " L1,L2,L3,L12 " and add them : Ltotal = 73.5
+105+54.5+20 = 253

This is such a simple thing to try out. Boot up ANSYS, start a new
problem, write the 5 lines of code and see if Ltotal contains the
variable.

Christopher Wright P.E. |"They couldn't hit an elephant at
chrisw@skypoint.com | this distance" (last words of Gen.
.......................................| John Sedgwick, Spotsylvania
1864)
http://www.skypoint.com/members/chrisw/



+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
Ernst Hustedt
Guest





PostPosted: Thu Jul 10, 2014 1:09 am  Reply with quote

On 8/07/2014 23:23, BOUILLON Nicolas wrote:
Quote:
Thanks a lot for your answers !

The problem is that I have 200 parameters to add and it will be desirable
to have a macro which select parameters that i want (for example : L%i%
with i =1,2,3,...)...

Nicolas,

Unfortunately you can't select variables like other entities.


If you want a macro to do the sums and assuming your variables are named
as above 'L%i%':

L_tot = 0
do_sum,1,2,3,12


where the macro 'do_sum' does sum, e.g.:

L_tot = L_tot + L%ARG1% + L%ARG2% + L%ARG3% + L%ARG4%

To make the number of passed variables arbitrary you could use a loop
and stop looping when the first ARGxx (max. ARG19) encountered is LT.1.
If you have more to add repeat the 'do_sum,,,, ' until you are done.
You could also use a n1,n2,n3 defining a series with n3 as increment or
any other way you fancy.

Ernst Hustedt
AMES Ltd,
Chch, NZ

+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
joseph.metrisin
User


Joined: 07 May 2009
Posts: 404

PostPosted: Thu Jul 10, 2014 3:43 am  Reply with quote

You could use an array parameter instead of individual scalar parameters. Then, use the second column of the array to define a selection vector. Set this to one if you want to add it to the summation, zero if not. Then use this column as a mask vector and do a summation.

*dim,mydata,array,numrows,2 ! dimension arrary
Mydata(1,1)=xxx $mydata(1,2)=1 ! This data will be summed
Mydata(2,1)=yyy $mydata(2,2)=0 ! This data will not be summed
:
:
*vmask,mydata(1,2) ! Set mask vector
*vscfun,mysum,sum,mydata(1,1) ! Calculate summation



-;
Joseph T Metrisin
Structures Lead
Florida Turbine Technologies, Inc
1701 Military Tr. Suite 110
Jupiter, FL 33458 U.S.A.
+1 (561)427-6346 Office

(561)427-6191 Fax
JMetrisin@fttinc.com

Visit our website: www.fttinc.com

FTT's public email encryption keys are stored on the FTT Verified Directory at http://keys.fttinc.com

-----------------------------------------------------------------------------------------------------
Confidentiality Note:
The information contained in this transmission and any attachments are proprietary and may be privileged, intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you received this communication in error, please delete the message and immediately notify the sender via the contact information listed above.
-----------------------------------------------------------------------------------------------------

----Original Message-----
From: Xansys [mailto:xansys-bounces@xansys.org] On Behalf Of Ernst Hustedt
Sent: Thursday, July 10, 2014 4:10 AM
To: ANSYS User Discussion List
Subject: [FTT_SPAM] - Re: [Xansys] Add scalar parameters


On 8/07/2014 23:23, BOUILLON Nicolas wrote:
Quote:
Thanks a lot for your answers !

The problem is that I have 200 parameters to add and it will be
desirable
to have a macro which select parameters that i want (for example : L%i% with i =1,2,3,...)...

Nicolas,

Unfortunately you can't select variables like other entities.


If you want a macro to do the sums and assuming your variables are named as above 'L%i%':

L_tot = 0
do_sum,1,2,3,12


where the macro 'do_sum' does sum, e.g.:

L_tot = L_tot + L%ARG1% + L%ARG2% + L%ARG3% + L%ARG4%

To make the number of passed variables arbitrary you could use a loop and stop looping when the first ARGxx (max. ARG19) encountered is LT.1.
If you have more to add repeat the 'do_sum,,,, ' until you are done.
You could also use a n1,n2,n3 defining a series with n3 as increment or any other way you fancy.

Ernst Hustedt
AMES Ltd,
Chch, NZ

+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+
+-------------------------------------------------------------+
| XANSYS web - www.xansys.org/forum |
| The Online Community for users of ANSYS, Inc. Software |
| Hosted by PADT - www.padtinc.com |
| Send administrative requests to xansys-mod@tynecomp.co.uk |
+-------------------------------------------------------------+

Post generated using Mail2Forum (http://www.mail2forum.com)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    XANSYS Forum Index -> XANSYS
All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

sleek template created by Andrew Charron