0
$\begingroup$

In physical problems the infinite force is easily implemented by the mathematical form of that force, take $1/r$ as an example, whenever the distance between two particles becomes small the force goes to infinity.

But, I want to simulate a system using agent-based modeling which the force between two objects becomes infinity without any mathematical form, my question is: Can the type of force below be implemented in a computer simulation? If so, how is it done?

$$f_{ij} = \hat{r}_{ij}\begin{cases} -\infty &\text{if } r_{ij} < r_\text{hc}\\ \frac{1}{4}\frac{r_{ij} - r_e}{r_a - r_\text{hc}} &\text{if } r_\text{hc}<r_{ij}<r_a\\ 1 &\text{if } r_a< r_{ij}<r_c \end{cases}$$

This equation is from a paper which has the arxiv version.

$\endgroup$
  • 2
    $\begingroup$ Welcome to SciComp.SE! Can you explain a bit more what you're trying to do? There is no "infinite force" in physical problems -- some terms might become infinite, but usually only if they are evaluated somewhere where they shouldn't be (for example, the $1/r$ potential describes the force acting on other bodies, for which $r$ is always greater than zero). $\endgroup$ – Christian Clason Aug 20 '16 at 7:57
  • $\begingroup$ Thank you! I completed my question by including the exact form of the equation. $\endgroup$ – user_10 Aug 21 '16 at 10:20
  • $\begingroup$ Maybe somebody will take the time to read the paper, but that normally happens when you get somebody interested in your question. Right now, it is not clear. $\endgroup$ – nicoguaro Aug 22 '16 at 18:45
  • $\begingroup$ The question of how to "implement infinity in code" is going to give Readers a difficulty in understanding what the implementation is supposed to accomplish. While IEEE 754 arithmetic includes a specification for representing signed infinities, whether a programming language is able to make use of such representations in a useful way depends on the language and on what you are trying to do (neither of which is supplied in the Question at present). $\endgroup$ – hardmath Sep 18 '16 at 19:47
  • 1
    $\begingroup$ user_10, the equation that you see in the paper does not mean that a numerical value for infinity is ever used. It is a mathematical (or physical) shortcut, or an abuse of language, that means that the distance between the particles can never be smaller than a given value. It has to be implemented in practice by, for instance, detecting collisions between particles and reflecting them appropriately. $\endgroup$ – Pierre de Buyl Sep 22 '16 at 12:15
1
$\begingroup$

In the same way you would do to implement a comparison with zero. For instance, in numerical solvers, one sometimes needs to check whether a value reaches zero. That is not feasible in a formal way since a real cannot be compared with zero due to the limitation of machine precision. A way to do that is to choose a precision $eps$ and compute : $$ \vert u \vert < eps $$ If you want to check whether $u$ "equals" 2, you do : $$ \vert u-2 \vert < eps $$ Generally you choose $eps$ to be near the machine precision limit, like $10^{-15}$

Now, to "compute" infinity, there is not a formal way to do that too since infinity is not a number so I would say to do the opposite, that is to say to choose a very big number, I often use $10^{20}$, that is what we do for instance in penalization method where we want a term overwhelming the others. If $F$ is the force you want to be infinite, just replace its value with a very big number.

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.