Please login with a confirmed email address before reporting spam
Posted:
9 years ago
Feb 21, 2016, 10:53 a.m. EST
Hello? Can somebody help?
Hello? Can somebody help?
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
Feb 23, 2016, 9:29 a.m. EST
I guess I found how to do this. You need to generate three random numbers using the random function in COMSOL. Let's say these numbers are a, b, and c. Using the expression bellow you can generate components of unit vectors with random orientations. Multiply them with the magnitude of your desired vector and you get vectors with same magnitude but random orientations.
a'=a/sqrt(a^2+b^2+c^2)
b'=b/sqrt(a^2+b^2+c^2)
c'=c/sqrt(a^2+b^2+c^2)
I guess I found how to do this. You need to generate three random numbers using the random function in COMSOL. Let's say these numbers are a, b, and c. Using the expression bellow you can generate components of unit vectors with random orientations. Multiply them with the magnitude of your desired vector and you get vectors with same magnitude but random orientations.
a'=a/sqrt(a^2+b^2+c^2)
b'=b/sqrt(a^2+b^2+c^2)
c'=c/sqrt(a^2+b^2+c^2)
Gunnar Andersson
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
Feb 24, 2016, 2:12 a.m. EST
This is a decent approximation, but you don't get a uniform distribution over set of directions.
This is a decent approximation, but you don't get a uniform distribution over set of directions.
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
Mar 2, 2016, 3:42 p.m. EST
This is a decent approximation, but you don't get a uniform distribution over set of directions.
Do you know any alternatives?
[QUOTE]
This is a decent approximation, but you don't get a uniform distribution over set of directions.
[/QUOTE]
Do you know any alternatives?
Gunnar Andersson
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
Mar 3, 2016, 2:31 a.m. EST
Do you know any alternatives?
For a mathematical question such as yours I think that Google is a faster way to find an answer than this forum: Search for e.g. "random vector sphere".
[QUOTE]Do you know any alternatives?[/QUOTE]
For a mathematical question such as yours I think that Google is a faster way to find an answer than this forum: Search for e.g. "random vector sphere".
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
Aug 16, 2016, 11:48 a.m. EDT
I'm having the same problem. So, let me give it a try.
Let's say the magnitude of the vector is equal to N and the direction of the vector varies with time.
For 2D simulation, I think one can create a random function (named rn1) with uniform distribution that ranges from -pi to pi (or 0 to 2*pi). By doing so, the x-compnent and y-compoent of the vector correspond to N*cos(rn1(t)) and N*sin(rn1(t)).
As for 3D simulation, I think it is just in analogy to spherical coordinate. If one creates two random functions both ranging from -pi to pi, then
x-component: N*sin(rn1(t))*cos(rn2(t))
y-component: N*sin(rn1(t))*sin(rn2(t))
z-component: N*cos(rn1(t))
Am I right about this?
I'm having the same problem. So, let me give it a try.
Let's say the magnitude of the vector is equal to N and the direction of the vector varies with time.
For 2D simulation, I think one can create a random function (named rn1) with uniform distribution that ranges from -pi to pi (or 0 to 2*pi). By doing so, the x-compnent and y-compoent of the vector correspond to N*cos(rn1(t)) and N*sin(rn1(t)).
As for 3D simulation, I think it is just in analogy to spherical coordinate. If one creates two random functions both ranging from -pi to pi, then
x-component: N*sin(rn1(t))*cos(rn2(t))
y-component: N*sin(rn1(t))*sin(rn2(t))
z-component: N*cos(rn1(t))
Am I right about this?
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
Aug 16, 2016, 4:47 p.m. EDT
No, that's not correct. Things are different on a sphere!
Being curious I followed Gunnar's advice and in less than a minute I found:
mathworld.wolfram.com/SpherePointPicking.html
wolfram.com is frequently a very good resource for mathematics.
Cheers
Edgar
--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
No, that's not correct. Things are different on a sphere!
Being curious I followed Gunnar's advice and in less than a minute I found: http://mathworld.wolfram.com/SpherePointPicking.html
wolfram.com is frequently a very good resource for mathematics.
Cheers
Edgar
--
Edgar J. Kaiser
emPhys Physical Technology
http://www.emphys.com
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
Aug 16, 2016, 9:23 p.m. EDT
Hi Edgar,
Thanks for your reply. I finally know how to solve problem correctly.
Hi Edgar,
Thanks for your reply. I finally know how to solve problem correctly.