Solving Toroid: Monte-Carlo Method Homework

  • Thread starter Thread starter unscientific
  • Start date Start date
  • Tags Tags
    Method
Click For Summary
SUMMARY

The discussion focuses on solving a homework problem involving the mass, center of mass, and moment of inertia of a toroid using the Monte Carlo method. The user successfully calculated the mass and center of mass by sampling points within the toroidal volume and applying the formula for center of mass. The moment of inertia was approximated using the number of partitions of the volume and the sampled coordinates. The final values obtained for the moments of inertia were mixx = 82, miyy = 140, and mizz = 210.

PREREQUISITES
  • Understanding of Monte Carlo methods for numerical integration
  • Familiarity with the concepts of mass, center of mass, and moment of inertia
  • Basic knowledge of C programming for implementing the algorithm
  • Ability to work with random number generation and statistical sampling
NEXT STEPS
  • Explore advanced Monte Carlo integration techniques for higher accuracy
  • Learn about the mathematical derivation of the moment of inertia for complex shapes
  • Investigate optimization techniques for Monte Carlo simulations in C
  • Study the implications of varying density in toroidal shapes on mass calculations
USEFUL FOR

Students studying physics or engineering, programmers implementing numerical methods, and anyone interested in computational geometry and simulation techniques.

unscientific
Messages
1,728
Reaction score
13

Homework Statement



Hi everyone, I'm supposed to find the mass, centre of mass and moment of inertia of a toroid. The basic idea I have is:

a)Take a sample of N set of points (x,y,z)
b)Assign a value of 1 to each correct set of (x,y,z) that lie in the toroid (by seeing whether it satisfies the equation)
c)Sum up all the number of correct sets
d)Ratio R is defined as the sum/N
e)Volume of shape is R*(volume of region, which is usually a box)

Assuming p = 1 as in the question, I've managed to find the mass and centre of mass.

2im4553.png


The Attempt at a Solution



The centre of mass Ixx is defined as mixx. I basically found the mass by simply finding the volume of the shape * 1 as ρ = constant = 1. For the centre of mass, I took the Ʃ(xcorrect * 1)/(number of correct sets) which simply gives the average x..

But for mixx i have this idea:
1. The number of sets of Ʃ(y^2 + z^2) you can take before you finish summing up the entire volume depends on how many partitions the volume is split up into.
2. Thus the number of sets taken is simply the number of partitions = Volume/number of correct sets

This gives a value for mixx to be around 82, miyy 140, mizz, 210

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()

{

	int i=1;
	double x;
	double y;
	double z;
	int s;
	double p;
	double v;
	double cmx1;
	double cmx2;
	double cmy1;
	double cmy2;
	double cmz1;
	double cmz2;
	double mixx1;
	double mixx2;
	
	srand48(time(NULL));
	
	while (i<=100000)
		
	{
		x = 1 + 3 * (drand48());
		
		y = 4 - 7 * (drand48());
		
		z = 1 - 2 * (drand48());
		
		if ( x*x + y*y + z*z - 6*sqrt(x*x + y*y) <= -8)
		{s = 1;}
		else 
		{s = 0;}
		
		
		
		p = p + s;
		
		v = (p/i)*42;
		
		cmx1 = cmx1 + x*s;
		cmy1 = cmy1 + y*s;
		cmz1 = cmz1 + z*s;
		
		cmx2 = cmx1/p;
		cmy2 = cmy1/p;
		cmz2 = cmz1/p;
		
		mixx1 = mixx1 + (pow(y,2) + pow(z,2))*s;
		mixx2 = (mixx1/p)*v;
		
		i++;
		printf("%d \t %.0f \t %f \t %f \t %f \t %f \t %f \t %f\n", s, p, v, cmx2, cmy2, cmz2, mixx1, mixx2);
		
	}
	
}
 
Last edited:
Physics news on Phys.org
bumpp?
 
Nevermind, problem solved!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K