yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23412
Re: [Question #691584]: About periodic simple shear
Question #691584 on Yade changed:
https://answers.launchpad.net/yade/+question/691584
Status: Open => Answered
Jan Stránský proposed the following answer:
Because you can easily choose one scenario or the other just by replacing 0 with 1 or vice versa.
The value "0" or "1" is not hardcoded, it is there to enable quick and easy selection.
If you know your final script needs just the "else" scenario, then just write that one.
But in the case of the chosen script, you can choose loose packing or you can choose densePacking.
If you let "if 0:", then you are using loose packing
If you change it to "if 1:", then you are using dense packing.
Then if you change it back to "if 0:", you use loose packing.
Then ...
everything by changing just one symbol. That is the meaning of it.
You could modify it e.g. in a more readable (but more verbose at the same time) code:
###
useLoosePacking = True
useDensePacking = False
# check that exactly one value is set to True
assert useLoosePacking or useDensePacking is True # at least one is True
assert useLoosePacking and useDensePacking is False # not both are True
#
if useLoosePacking:
createLoosePacking() # possibly a long code block
elif useDensePacking:
createDensePacking() # possibly a long code block
###
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.