-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify control point nudge for 1D elements #120
Comments
For a small number that is just large enough for Python to distinguish the
distance, what about using numpy.spacing(n)? Where n is some small number
that lets your tests pass.
…On Mon, Nov 11, 2024 at 7:30 AM Davíd Brakenhoff ***@***.***> wrote:
Currently, the control point locations inside and outside an element are
computed by multiplying 1 plus a small number (1E-6) by the absolute value
of the coordinate and adding/subtracting that to the location of the
element.
self.xcin = self.xc + self.tiny * abs(self.xc) + self.tiny
For large values of the coordinate (which to be fair is probably rare for
cross sectional models), this causes large distances between the element
and its control points inside/outside, which isn't what we want.
Proposal is to replace the above by just adding/subtracting a small
number. Optionally we can consider exposing the small number as a keyword
argument in the elements.
self.xcin = self.xc + self.tiny
—
Reply to this email directly, view it on GitHub
<#120>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFCIYHLUIWKA2OC3LX4TH32ACWO3AVCNFSM6AAAAABRR3HBPOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY2DSMZVG4YDIOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Interesting, I didn't know about |
Consider this case, I think it may apply in the context of interest, but
you can judge:
Suppose a world coordinate system with numerically very large numbers.
An element with endpoints z1 and z2, and center z0: (conveniently for
writing, it's on the real axis)
z1 = 1.0e9 + 0j
z0 = 1.1e9 + 0j
z2 = 1.2e9 + 0j
The mapping from z to Z would be
Z(z) = (z - z0) * r
The element length in Z will be 2, so r = 2/(z2-z1)
>> z1, z0, z2 = 1.0e9, 1.1e9, 1.2e9
>> r = 2 / (z2 - z1)
1e-08
Now, define a control point c1 close to z1, and offset from the boundary in
direction 1j.
>> z1
1000000000.0
>> c1 = z1 + 1j * (np.spacing(z1))
(1000000000+2.384185791015625e-07j)
Map c1 to the Z-plane: C1 = Z(c1) = (c1 - z0) * r
>> C1 = (c1 - z0) * r
(-1+2.384185791015625e-15j)
C1 is measurably off of the real axis.
…On Mon, Nov 11, 2024 at 7:47 AM Davíd Brakenhoff ***@***.***> wrote:
For a small number that is just large enough for Python to distinguish the
distance, what about using numpy.spacing(n)? Where n is some small number
that lets your tests pass.
Interesting, I didn't know about np.spacing. But machine precision is
probably a little too small for this, I think.
—
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFCIYBYAJBUDBKTG7JASZD2ACYPJAVCNFSM6AAAAABRR3HBPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRYGIZDCMRQGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi Bill, thanks for the suggestion and worked example, I'll give it a try! The reason I wasn't sure initially is because so far we've used shifts on the order of ~1e-6, and I wasn't sure if in 2D we wouldn't be running into any floating point precision stuff with some of the methods to determine whether a point is inside or outside a polygon, etc. |
Currently, the control point locations inside and outside an element are computed by multiplying 1 plus a small number (1E-6) by the absolute value of the coordinate and adding/subtracting that to the location of the element.
For large values of the coordinate (which to be fair is probably rare for cross sectional models), this causes large distances between the element and its control points inside/outside, which isn't what we want.
Proposal is to replace the above by just adding/subtracting a small number. Optionally we can consider exposing the small number as a keyword argument in the elements.
The text was updated successfully, but these errors were encountered: