in reply to Metropolis Monte Carlo

For some reason, my previous and new energies are often identical despite moving am atom in space...

Perhaps this has something to do with it?

sub total_energy { my $totalE = 0; foreach my $i ( 0 .. $#arrayx ) { foreach my $j ( $i + 1 .. $#arrayx ) { my $r = sqrt( ($arrayx[$i] - $arrayx[$j])**2 + ($arrayy[$i] - $arrayy[$j])**2 + ($arrayz[$i] - $arrayz[$j])**2 ); $totalE = $totalE + vdw( $r ); return $totalE; } } }

You set up nested loops to iterate over your atoms and calculate your total energy, but then unconditionally return from inside both loops after their first iterations.

If you moved the return to the end of the subroutine, it would make a big difference. (It might not totally fix things, but it should help.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?