Search:
Type: Posts; User: 2kaud
Search:
Search took 0.07 seconds.
-
April 15th, 2014, 04:14 PM
No
If delta_E <= 0 then flip
if delta_E > 0 then flip if exp(-delta_E) > random_number_0_to_1
When evaluating logical or conditions, the left hand expression is evaluated first. If this is...
-
April 15th, 2014, 01:55 PM
if (delta_E <= 0 || ((double)rand() / (double)(RAND_MAX)) < (double)exp((double)-delta_E))
the if condition is a logical or. If either or both of the seperate conditons (left and right of the ||)...
-
April 15th, 2014, 01:39 PM
To store data in a file, you first need to open the file for writing and then output data to the file. Data can be written to the file using stream insertion (just like << for cout).
See...
-
April 14th, 2014, 11:10 AM
Well as long as it seems then that's all right then? Have you tested it to make sure it gives the answers expected? I don't think it will as x and y are only set once at the beginning of the program...
-
April 14th, 2014, 04:36 AM
Fine. So just do the quick change to the code so that it matches what you want to do and then you'll have it.
-
April 13th, 2014, 08:34 AM
Not really. If you want x and y to selected differently for each loop then the for needs to be before the int x. Do you want neighbour etc to be reset each time around the loop or values covering all...
-
April 13th, 2014, 04:33 AM
What is the variable T? || in c++ conditional expression means logical OR. ie if either or both of the conditions are met then the condition is evaluated to TRUE. drand48() returns a random number in...
-
April 12th, 2014, 04:21 PM
Yes, as in maths the x-axis should go left to right and the y-axis go top to bottom.
?? :confused:
This comes back to what is meant by a sweep? During one sweep can the same element be...
-
April 12th, 2014, 12:44 PM
Upon looking at the code I put together from your previous postings, there appears to be inconsitencies between which element of the matix is considered to be x and which to be y. I think the code...
-
April 12th, 2014, 10:39 AM
If you are using Windows 7 why don't you use the free Microsoft Visual Studio Express 2013?
See http://www.visualstudio.com/downloads/download-visual-studio-vs
You want Visual Studio Express 2013...
-
April 12th, 2014, 04:14 AM
spin(x, y) *= -1; // flip spin
As the class is currently coded, you can't do this as operator() returns a value not a reference. You need to change operator() to
int& operator()(int x,...
-
April 11th, 2014, 02:02 PM
If you haven't met c++ classes before, you need a crash course in them.
See
http://www.learncpp.com/cpp-tutorial/82-classes-and-class-members/
http://www.cplusplus.com/doc/tutorial/classes/...
-
April 11th, 2014, 12:14 PM
No. There is no implied boundary conditions in your code. That is why you are getting absurd values. The boundary conditions need to be part of spin() - so spin() needs to be function instead of just...
-
April 11th, 2014, 11:05 AM
if(x<0) x += LatSize;
if(x>=LatSize) x -= LatSize;
if(y<0) y += LatSize;
if(y>=LatSize) y -= LatSize;
these statements are not needed as x and y will always satisfy the condition >= 0 and...
-
April 11th, 2014, 04:31 AM
int x = int (rand()*LatSize);
int y = int (rand()*LatSize);
What's with the '*' ? It should be % (modulo) as per my post #2!
int x = int (rand()%LatSize);
int y = int (rand()%LatSize);
-
April 11th, 2014, 04:18 AM
I agree - that's why I said in my post #10 that the easiest way would be to do text-replace. :) I only offered the #define as an option to try to get the code posted by the OP to compile as I...
-
April 10th, 2014, 10:39 AM
Like this
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
#define spin(a, b) (matrix[(a)][(b)])
-
April 10th, 2014, 04:32 AM
Possibly the easiest way is to replace spin(...) by matrix[...].
Another way would be to use a define at the top of the code
#define spin(x,y) (matrix[(x)][(y)])
-
April 9th, 2014, 05:16 PM
As I explained in my previous post #2. What is the function spin? This is being used but isn't defined.
-
April 9th, 2014, 05:10 PM
Please use code tags when you post code as you did in post #1.
As ROWS and COLS are now not defined, you could use
const int LatSize = 5;
int matrix[LatSize][LatSize];
...
-
April 9th, 2014, 04:54 PM
I'm not sure I fully understand what you are trying to accomplish. However, looking at the code I can offer some observations which may be of help.
With reference to your NxN lattice. As the...
|
Click Here to Expand Forum to Full Width
|