3

So I have tried various ways, but I am still new to TikZ and have only produced a few TikZ graphics, so forgive me if I've done some stupid mistakes.

I have a LaTeX project I need to hand in, and I thought that I might give TikZ a try to replicate one of the figures we got provided with in our script for our experiment. (I thought that it might look nicer to have everything matching in the same document rather than different figure styles.)

This is what I am trying to replicate with TikZ:

Dimer-Grafik

I have managed to replicate the right part (and other figures, see below), but I can not ge the parabola to smoothing join the join on the right.

The hobby tikzlibrary looked promissing, but did not quite get me to where I wanted to.

My code sofar:

\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{positioning,intersections,calc,hobby}
\begin{document}
    \begin{tikzpicture}
        \bgroup
        \sffamily
        
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Styles
        %%%%%%%%%%%%%%%%%%%%%%%%%
        \tikzset{
            axisstyle/.style={
                very thick,
                ->, 
                > = stealth
            },
            relaxed-state/.style={
                black,
                very thick
            },
            abs-em/.style={
                very thick,
                ->,
                > = stealth,
                black
            },
            excited-lines/.style={
                very thick,
            },
            energy-level/.style={
                very thick,
                black,
                dashed
            }
        }
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Grafik
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Nodes
        \node (left-S0) at (5,2) {};
        \node (left-S1) at (5,6) {};
        %       \node (parabola-min) at ($ (left-S1)+(-1.5,-0.5) $) {};
        \node (S0-parab-min) at ($ (left-S0)+(-1.5,-1) $) {};
        \node (S0-parab-max) at ($ (left-S0)+(-4,2) $) {};
        
        % Achse
        \draw[axisstyle] (1.5,0) -- node[below] (axis label) {Intermolekularer Abstand $R$} (10,0);
        
        % Relaxed states S0 and S1
        \draw[relaxed-state] (left-S0.center) -- node[below right] (S0) {\color{green} B\,$+$\,B\hphantom{$^*$}} +(4,0);
        \draw[relaxed-state] (left-S1.center) -- node[above right] (S1) {\color{red} B\,$+$\,$\mathsf{B}^*$} +(4,0);
        
        % Abs., Em., Monomeren
        % Version 1: Node in arrows
        \draw[abs-em] (S0.north west) -- node[fill=white] (abs) {Abs.} (S1.south west);
        \draw[abs-em] (S1.south east) -- node[fill=white] (em) {Em.} (S0.north east);
        \node[above=of abs.west,fill=white,yshift=-6mm,anchor=west] (Monomeren) {Monomeren};
        
        % Version 2: Node next to arrwos
        %           \draw[abs-em] (S0.north west) -- node[fill=white,left] (abs) {Abs.} (S1.south west);
        %           \draw[abs-em] (S1.south east) -- node[fill=white,right] (em) {Em.} (S0.north east);
        
        % parabola form of energy levels
        
        %%%%%%% my try with the hobby library
        
        % notes for the important parts of the figure:
        % the minimum of the parabolas must not be at the same x value
        % the upper parabola (S1 parabola) has to be "tighter" than the lower (S0 parabola)
        % energy levels have to be drawn
        
        %           \draw[excited-lines] (left-S0.center) to[out=180] (S0-parab-min) to (S0-parab-max);
        %           \draw[excited-lines] (left-S0.center) to[curve through={($ (left-S0.west)+(-0.5,-0.5) $)}] (S0-parab-min);
        \draw[excited-lines] (left-S0.center) to[curve through={($ (left-S0.west)+(-1,-0.5) $) .. (S0-parab-min)}] ++(-5,2); 
        \egroup
    \end{tikzpicture}
\end{document}

Which gives: Dimer-replicate-try

4
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented Oct 3, 2021 at 11:06
  • @hpekristiansen Ok sry for not including that. I have edited the question now. Commented Oct 3, 2021 at 11:12
  • Your code is not compilable. Commented Oct 3, 2021 at 11:21
  • @hpekristiansen Sry had to remove other stuff (grid macro) and put the tikzlibraries after \begin{document} by accident Commented Oct 3, 2021 at 11:24

2 Answers 2

3

The start and end angle can be controlled with out and in. Here I only post a single line of code, because you have a lot of code not relevant to the problem:

\draw[excited-lines] (left-S0.center) to[curve through={($ (left-S0.west)+(-1,-0.5) $) .. (S0-parab-min)}, in angle=-70] ++(-5,3); 

Approx. parabola plot

I would use the "correct" potential energy function like this:

\documentclass[tikz, border=1 cm]{standalone}
\begin{document}
\begin{tikzpicture}
\newcommand{\xmin}{1}
\draw[teal, thick] plot[domain=0:4, samples=100] ({\x}, {(1-exp(-(\x)+\xmin))^2});
\end{tikzpicture}
\end{document}

Potential function

4
  • Thank you for baring with me and still answering my question after my initial problems with providing the necessary code. Just a quick follow-up question: how do you connect the parabola / potential line with the horizontal one without getting a small gap between them? Commented Oct 3, 2021 at 12:42
  • There is no true parabola - do you mean the first solution? If the two curves end/start in the same point, there is no gap. Possible, your viewer will display a a very small gap, but that is just a viewer artefact. To avoid this, you need the two curves in the same \draw command connected with --. Commented Oct 3, 2021 at 12:58
  • Note that coordinates has no extension, so (left-S0.center) does not make sense - simply use (left-S0). Commented Oct 3, 2021 at 13:00
  • Ok thx. Then that might be an artefact of the viewer. Thx for the hint that center is not needed here. Commented Oct 3, 2021 at 13:02
4

For the purpose of drawing a parabola, I suggest to use the parabola bend option for \draw:

\draw[olive,excited-lines] (S0-parab-max) parabola bend (S0-parab-min) ($(left-S0)+(-1,-0.5)$) to [in=180] (left-S0);

parabola smoothly linked to line

Complete code:

\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{positioning,intersections,calc,hobby}
\begin{document}
    \begin{tikzpicture}
        \bgroup
        \sffamily
        
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Styles
        %%%%%%%%%%%%%%%%%%%%%%%%%
        \tikzset{
            axisstyle/.style={
                very thick,
                ->, 
                > = stealth
            },
            relaxed-state/.style={
                black,
                very thick
            },
            abs-em/.style={
                very thick,
                ->,
                > = stealth,
                black
            },
            excited-lines/.style={
                very thick,
            },
            energy-level/.style={
                very thick,
                black,
                dashed
            }
        }
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Grafik
        %%%%%%%%%%%%%%%%%%%%%%%%%
        % Nodes
        \coordinate (left-S0) at (5,2) ;
        \coordinate (left-S1) at (5,6) ;
        %       \coordinate (parabola-min) at ($ (left-S1)+(-1.5,-0.5) $) ;
        \coordinate (S0-parab-min) at ($ (left-S0)+(-2,-1) $);
        \coordinate (S0-parab-max) at ($ (left-S0)+(-4.5,2) $);
        
        % Achse
        \draw[axisstyle] (1.5,0) -- node[below] (axis label) {Intermolekularer Abstand $R$} (10,0);
        
        % Relaxed states S0 and S1
        \draw[relaxed-state] (left-S0.center) -- node[below right] (S0) {\color{green} B\,$+$\,B\hphantom{$^*$}} +(4,0);
        \draw[relaxed-state] (left-S1.center) -- node[above right] (S1) {\color{red} B\,$+$\,$\mathsf{B}^*$} +(4,0);
        
        % Abs., Em., Monomeren
        % Version 1: Node in arrows
        \draw[abs-em] (S0.north west) -- node[fill=white] (abs) {Abs.} (S1.south west);
        \draw[abs-em] (S1.south east) -- node[fill=white] (em) {Em.} (S0.north east);
        \node[above=of abs.west,fill=white,yshift=-6mm,anchor=west] (Monomeren) {Monomeren};
        
        % Version 2: Node next to arrwos
        %           \draw[abs-em] (S0.north west) -- node[fill=white,left] (abs) {Abs.} (S1.south west);
        %           \draw[abs-em] (S1.south east) -- node[fill=white,right] (em) {Em.} (S0.north east);
        
        % parabola form of energy levels
        
        %%%%%%% my try with the hobby library        
        
        \draw[olive,excited-lines] (S0-parab-max) parabola bend (S0-parab-min) ($(left-S0)+(-1,-0.5)$) to [in=180] (left-S0);
        \egroup
    \end{tikzpicture}
\end{document}

You can adapt this to the rest of your code and ask another question regarding the energy levels if you don't find a nice way to add them.

2
  • Thank you for answering my question. Just a quick follow-up question: how do you connect the parabola / potential line with the horizontal one without getting a small gap between them? Can one use the foreach loops for intersections and the energy levels? Commented Oct 3, 2021 at 12:53
  • You definitely can use foreach with intersections. I would do like this.
    – SebGlav
    Commented Oct 3, 2021 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .