Recent content by ggeo1

  1. G

    Periodic boundary conditions for 2d grid

    Ok, i use in this exmaple a grid size with dimensions Nx,Ny (4x4). The 'particle' will be initial at position xpos,ypos.Then you choose a step in both sirections (stepx,stepy) and you must calculate the new position (xpos,ypos) after applying the periodic boundary conditions)...
  2. G

    Periodic boundary conditions for 2d grid

    I mean , i am confused at how to return xup,xdown to new xpos and yup ,ydown to new ypos. Ok , use a structure but how to relate xup and xdown with xpos? Thank you
  3. G

    Periodic boundary conditions for 2d grid

    Hello , ok for all you say but you don't answer to my questions. :)
  4. G

    Periodic boundary conditions for 2d grid

    Hello , i am trying to implement this algorithm for 2d grid. 1) i am not sure if my calculations are correct. 2 ) i don't understand how to return my final calculation ( how will i insert to the matrix i want (the 's' in this example) the new coordinates (xup,xdow,yup,ydown)). I mean ...
  5. G

    Compute Electric Field from Electric Currents

    Ok , thanks!
  6. G

    Compute Electric Field from Electric Currents

    I think it's ((J*R) *C_2 )*R , where R i will put R_x? Then for E_y i will put R_y?
  7. G

    Compute Electric Field from Electric Currents

    Hello and thanks for the help. C_1 and C_2 are scalars. So, ok J*R=..=scalar. But i can't understand how to do the (J*R|R*C_2) . I will compute the J*R and then the R*C_2 , and then what?
  8. G

    Compute Electric Field from Electric Currents

    Hello, I have this equation that computes the electric field from electric currents. E=-j*k_n (J*C_1- (J*R|R*C_2) e^ -j*k*R/4πR ) The data are: k_n=377 , k=20.93 , R=Sqrt(3) ,J_x=0.72576821 ,J_y=0.03763659 , J_z=0.86104220 , C_1=0.999239077741 + 1 / 36.2518234024j...
  9. G

    C/C++ Solving Gauss-Legendre Algorithm in C++

    Hello , i have the algorithm attached. the compiler gives me the following errors: where i have "t=new double [x];" it gives -> error: expression in new-declarator must have integral or enumeration type| and where " result=w*f(*t); " ->error: invalid operands of types ‘double*’...
  10. G

    C/C++ Solving Gauss-Legendre Algorithm in C++

    Hello , i have the algorithm attached and i am trying to execute it in c++. My code until now is : ( i have created the function f with limits (-1,1) ) #include <iostream> #include <cstdio> #include <cstdlib> #include <iomanip> #include <cmath> using namespace std; const double...
  11. G

    C/C++ C++ simpson's method -loop doesn't stop

    Here is my code : #include <iostream> #include <cstdio> #include <cstdlib> #include <iomanip> #include <cmath> using namespace std; double f(double x){ double y; y=sqrt(x-0.1); return y; } double simpson (double down,double up,int n){ double...
  12. G

    C/C++ C++ simpson's method -loop doesn't stop

    I used the same code in mathematica and it works fine.It gives me the right answer after 2 iterations.The same is happening here but it continues to step 8.(it gives me the right result every "even" steps)..
  13. G

    C/C++ C++ simpson's method -loop doesn't stop

    Ok, i changed the for loops : for (int i=1;i<=n/2-1;i++) for (int i=1;i<=n/2;i++) (it was a mistake ,i didn't want to insert double values in the loops!) But now again , it gives me the exit as a say above..
  14. G

    C/C++ C++ simpson's method -loop doesn't stop

    Hello,you are right but if i do : int n=1;//initial point result=simpson(1.0,2.0,n); while (fabs(result-exact)>eps) { result=simpson(1.0,2.0,n); cout <<"\nFor n = "<<n<<",error = "<<fabs(result-exact)<<",value = "<<result; n++; } then the loop...
  15. G

    C/C++ C++ simpson's method -loop doesn't stop

    c++ simpson's method --loop doesn't stop Hello, i have done the simpson's method and it works fine.My problem is that it doesn't stop when it gives me the desired result but the loop continues for ever.. #include <iostream> #include <cstdio> #include <cstdlib> #include <iomanip> #include...
Back
Top