Fe-O EAM potential

I don’t know why the C code cannot be attached. I think it’s better to copy/paste it just here:

I don't know why the C code cannot be attached. I think it's better to
copy/paste it just here:

i think it is better that nobody sees this code.
this is one of the most extreme examples for how to *not* write C code
that i have seen in my life.
(and why C at all? is python too slow for you?)

axel.

i think it is better that nobody sees this code.
this is one of the most extreme examples for how to *not* write C code
that i have seen in my life.
(and why C at all? is python too slow for you?)
axel.

Well .... this code doesn't look as bad compared to my personal source
codes =). But Axel, can you please tell me what's wrong with the code
? or what improvement can be done? . Since i'm not a computer guru i'm
not able to see the errors ... I would really appreciate the feedback

Thanks
Oscar G.

The code is written for Iron-Oxygen systems and the reference is : Zhou - Wadley (J Phys Condens Matter 17 (2005) 3619)

soheil

i think it is better that nobody sees this code.
this is one of the most extreme examples for how to *not* write C code
that i have seen in my life.
(and why C at all? is python too slow for you?)
axel.

Well .... this code doesn't look as bad compared to my personal source
codes =). But Axel, can you please tell me what's wrong with the code
? or what improvement can be done? . Since i'm not a computer guru i'm
not able to see the errors ... I would really appreciate the feedback

i didn't say it was wrong. it is just a horrible style or programming.
almost as bad as computed GOTOs in fortran 4.

we have gratuitous abuse of the preprocessor for starters.
why are there variables in programming languages?
right, you can have the compiler/interpreter check their type.
a preprocessor just assembles strings.

second, there is useless use of the pow() function (what is x**0 ?)

and third, for something that is not time critical, writing as
readable and maintainable as possible is making it re-usable and
debuggable. so using a scripting language like python, matlab, perl,
Tcl, awk, bc, whatever seems a logical choice.

axel.

about the style, axel might be right.

but about “pow()”: I’m using MS Visual Studio 2005, which just compile pow() function for powers.
And I use matlab sometimes for some particular purposes, but generaly I use C. why? it’s my logical choice!

soheil

about the style, axel might be right.

but about "pow()": I'm using MS Visual Studio 2005, which just compile pow()
function for powers.

let me have you participate in a little "secret": pow(x,0.) for any
valid choice of x is simply 1.0

Aha! I got it.
The function “double OF (double rho)” shoule be revised.
because of the “wrong” powers!

double OF (double rho_){
if (rho_ < OrhoM0)
return (
OF00 +
OF10 * pow (rho_/Orhoe0-1., 1.) +
OF20 * pow (rho_/Orhoe0-1., 2.) +
OF30 * pow (rho_/Orhoe0-1., 3.));
else if (Orhom1 <= rho_ && rho_ < OrhoM1)
return (
OF01 +
OF11 * pow (rho_/Orhoe1-1., 1.) +
OF21 * pow (rho_/Orhoe1-1., 2.));
else if (Orhom2 <= rho_ && rho_ < OrhoM2)
return(
OF02 +
OF12 * pow (rho_/Orhoe2-1., 1.) +
OF22 * pow (rho_/Orhoe2-1., 2.));
else if (Orhom3 <= rho_ && rho_ < OrhoM3)
return(
OF03 +
OF13 * pow (rho_/Orhoe3-1., 1.) +
OF13 * pow (rho_/Orhoe3-1., 2.));
else if (Orhom4 <= rho_)
return(
OF04 +
OF14 * pow (rho_/Orhoe4-1., 1.) +
OF24 * pow (rho_/Orhoe4-1., 2.));
}

my predictions about this:

soon someone will let you know what’s pow(x,1.0)

my predictions about this:

soon someone will let you know what's pow(x,1.0)

why stop there? why not discuss some 200 year old stuff like horner's
rule http://en.wikipedia.org/wiki/Horner's_rule which is still a
pretty nifty way to evaluate polynomials. be it with a pencil and a
paper, be it with a computer. :wink:

axel.



:ok guys :))
I will go work with it and check if output is correct, you may discuss about programming style as long as you wish!


|

The presented method ignores the ionic energy, so, it should NOT be used without making modifications in lammps source files