4

I am trying to produce Bohr style diagrams of the elements. I have tried to use the Bohr package but although this produces something almost what I want, but does not show the orbit shapes or the makeup of the nucleus.

\documentclass{standalone}
\usepackage{tikz,graphicx}
\usetikzlibrary{decorations.markings}

\definecolor{myyellow}{RGB}{254,241,24} \definecolor{myorange}{RGB}{234,125,1}

\def\proton(#1,#2){% \fill[shading=ball,ball color=myyellow, opacity=0.75] (#1,#2) circle (10pt); \node at (#1,#2) {\texttt{+}}; } \def\neutron(#1,#2){% \fill[shading=ball,ball color=myorange, opacity=0.75] (#1,#2) circle (10pt); } \def\electron{% \fill[shading=ball,ball color=gray!30] (0,0) circle (5pt); \node at (0,0) {\texttt{-}}; } \def\sorbit(#1,#2){% \draw[ color=violet, rotate=#1, postaction=decorate, decoration={markings, mark=at position #2 with {\electron}, }] (0,0) ellipse (1.5 and 3.5); } \def\porbit(#1,#2){% \draw[ color=violet, rotate=#1, postaction=decorate, decoration={markings, mark=at position #2 with {\electron}, }] (0,0) ellipse (4 and 6); }

\begin{document}

Hydrogen \begin{tikzpicture} %H Nucleons \proton(0.2,-0.2)

%H orbits \sorbit(40,.9) \end{tikzpicture}

Helium \begin{tikzpicture} %He Nuclius \neutron(-0.1,0.1) \proton(0.2,-0.2) \neutron(-0.25,-0.5) \proton(-0.3,0.1) %He Orbit \sorbit(100,.3) \sorbit(50,0.8) \end{tikzpicture}

\end{document}

enter image description here

Does anybody know of a package which produces this so Ideally I could just type something like \H inside my tikz picture.

Also if any help on automating the location of the protons and neutrons so I don't have to do each one, one by one.

Have tried to use something like How to create nice-looking nuclei in TikZ? to produce the nucleus but just don't seem to make it work.

Paul A
  • 1,055
  • 4
  • 14

1 Answers1

7

Well, it's not a package, but maybe this does what you want.

We define a command

\Bohr[<tikz options>]{<protons>}{<neutrons>}{<electron sequence>}

TikZ options include scale, rotate, etc. Optional.

Examples:

\Bohr{1}{0}{1} % Hydrogen

enter image description here

\Bohr{3}{4}{2,1} % Lithium

enter image description here

\Bohr{13}{14}{2,8,3} % Aluminum

enter image description here

As you can see, the macro adjusts the scale, angle and eccentricity of the electron orbits.

Here is the code. You can easily adjust colors and sizes. There are many more adjustments possible, but I thought I'd see if this was the right idea before I worked any more on it.

\documentclass{article}

\usepackage{tikz, ifthen}

\tikzset{proton/.pic={\shadeshading=ball, ball color=protoncolor circle[radius=\protonradius];\node[black]{\tiny+};}, neutron/.pic={\shadeshading=ball, ball color=neutroncolor circle[radius=\neutronradius];}, electron/.pic={\shadeshading=ball, ball color=electroncolor circle[radius=\electronradius];\node[black]{\tiny-};}}

\colorlet{protoncolor}{yellow!90!black} \colorlet{neutroncolor}{orange!90!black} \colorlet{electroncolor}{gray!30} \colorlet{orbitcolor}{violet}

\newcommand{\protonradius}{2.5mm} \newcommand{\neutronradius}{2.5mm} \newcommand{\electronradius}{1mm}

\newcommand{\Bohr}[4][]{\tikz[#1]{\pgfmathtruncatemacro{\tot}{#2 + #3} \foreach \e[count=\j] in {#4}{\xdef\nume{\j}} \foreach \e[count=\j, evaluate=\e as \R using 3sqrt(#2+#3)/2] in {#4}{ \draw[orbitcolor, rotate=180/\nume\j+90/\nume] (0:\R) arc (0:360:{\R} and {\R/(\nume)}) foreach \s in {1,...,\e} {pic[pos=\s1/\e+.1]{electron}}; } \foreach \n[evaluate=\n as \r using sqrt((\n-1))/6, evaluate=\n as \t using 222.492236\n, ] in {\tot,...,1}{\pic at (\t:\r){neutron}; \foreach \x[evaluate=\x as \y using int(\tot/#2*\x)] in {1,...,#2} {\ifthenelse{\equal{\n}{\y}}{\pic at (\t:\r){proton};}{} } } }}

\begin{document}

\Bohr{1}{0}{1} % Hydrogen

\Bohr{3}{4}{2,1} % Lithium

\Bohr{13}{14}{2,8,3} % Aluminum?

\end{document}

Sandy G
  • 42,558