# Implementing simple atom model using density functional theory (DFT)

I am trying to write computer code which will find the energy and density function for an atom with $Z$ protons and $N$ electrons. I am working in 1D for simplicity and would like to make the overall code as simple as possible (I am using Hartree units aswell). I am using also using the Hartree approximation. This is my overall algorithm:

1. Finds hydrogen like wave-functions (i.e. no electron-election interaction)

2. Works out density function via $n(z) = \sum_i \left | \phi_i(z) \right |^2$

3. Works out Hartree potential $V_H(r) = \int_0^\infty \frac{n(\vec{s})}{\left | \vec{r}-\vec{s} \right |} d\vec{s}$

4. Uses Kohn-Sham equation to find new individual wavefuncitons $\left (-\tfrac{1}{2}\bigtriangledown^2 + \frac{Z}{\left |r \right |} + V_H(\vec{r}) + V_{EX}(\vec{r}) \right )\phi_i = \varepsilon_i \phi_i$

5. Go back to step 1. and repeat.

I am having a number of difficulty and would be very grateful for some help with any of my questions.

Firstly to compute the Hartree potential I need to turn it into a 1D problem, so we assume even spherical distribution of charge:

$V_H(r) = \int_0^\infty 4\pi s^2 \frac{ n(s)}{\left |r-s\right |} ds$

However this blows up when $r = s$. I have been looking into Gauss's law but had no luck.

Additionally, I am unsure how to compute the exchange-correlation term. I am trying to find a function which I can easily implement.

Any help would be great.

-
Coss-posted to Scientific Computation. Please don't do that, it is strongly discouraged. You should take you best guess at the best fit and only try another site if you don't get satisfactory results from the first instance. –  dmckee Mar 15 '12 at 20:31
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3731537163257599, "perplexity": 474.5952993643247}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2013-48/segments/1386163066095/warc/CC-MAIN-20131204131746-00040-ip-10-33-133-15.ec2.internal.warc.gz"}