4
$\begingroup$

I have a grid that I plan to discretize in 1D. It extends from 0 to L using N nodes, and I need to refine it at each end. I plan to have something that looks as follows:

enter image description here

I have tried the to specify these two parameters:

  1. growth rate (r)
  2. initial node spacing (dx1)

Then the x points are calculated in a series such as the following:

x(i) = dx1 * r ^ x(i-1)

This works fine if I know N, and specify r and dx1. But ideally, I would need r and dx1 to be functions of N to properly scale the grid when N increases. I.e. with N = 10, r should be about 1.7 but when N = 100, r should be about 1.1 to have the same "shape". Similar problem with dx1. Anyone know how to make those two parameters functions of N that will scale with it?

$\endgroup$
  • $\begingroup$ Something is not okay with your picture, try to insert it again. If it doesn't work, put in a link to it. $\endgroup$ – peterh Nov 16 '17 at 0:08
  • $\begingroup$ Hi @peterh, thanks for letting me know. I've fixed it now. $\endgroup$ – teepee Nov 16 '17 at 2:51
  • $\begingroup$ not clear what your notation means, but I don't think you want x_i = dx1 times r to the power x_(i-1) more likely x_i=dx1*r*x_(i-1) $\endgroup$ – agentp Apr 16 '18 at 21:12
1
$\begingroup$

I'm assuming that your equation is only used to define the spacing from an end to the middle, after which you mirror it.

Instead of dx1, write L / N, where L is the total length. Now you have

x(i) = (L / N) * r ^ x(i-1)

...and when you change N, your x(i)s will also scale. I don't think you want r to be a function of N.

Let me know if this helps!

$\endgroup$
0
$\begingroup$

Since 1D would likely not be too computationally intensive even for very large sets, you could just sum all the lengths for a given N, then divide all the distances in that mesh array by that value. It would not be computationally efficient like an explicit function, but will do exactly what you need without too much experimentation. If you need the computational efficiency and dont get any derrivations here, you may want to repost in mathamatics.

$\endgroup$
  • $\begingroup$ I'm not sure I know exactly what you mean by that; could you write it out numerically in some fashion if possible? Will this still be a geometric series? $\endgroup$ – teepee Nov 16 '17 at 23:38
  • $\begingroup$ Whar programming/scripting language are you using? Python is a good choice if you have not selected one. Basically use a FOR loop for n to build the array and sum the total length, then a second FOR loop to divide every item in the array by that sum. $\endgroup$ – ericnutsch Nov 17 '17 at 1:55
  • $\begingroup$ I'm using MATLAB atm. I understand the syntax of the operations, but I'm not sure exactly wat you mean about dividing every item by the sum... $\endgroup$ – teepee Nov 20 '17 at 19:20
  • $\begingroup$ You are having issues with the scale of the final grid based on different input values. If i know the total length (by summing it as i go in the first loop) and i divide every cell by the total (in a second loop after i know the total) then the sum of all the cell lengths in the grid will always be 1 regardless of the input parameters. $\endgroup$ – ericnutsch Nov 21 '17 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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