summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/modiagram/modiagram.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-09-27 00:26:06 +0000
committerKarl Berry <karl@freefriends.org>2011-09-27 00:26:06 +0000
commit01676138b054f69c805f47d0fead7b078b68cb36 (patch)
tree8dd849651d5124eb111baee19069193a5bab57be /Master/texmf-dist/tex/latex/modiagram/modiagram.sty
parentdd0741c4b28fd3f20a807772b4f5326a85a86812 (diff)
new package modiagram (26sep11)
git-svn-id: svn://tug.org/texlive/trunk@24106 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/modiagram/modiagram.sty')
-rw-r--r--Master/texmf-dist/tex/latex/modiagram/modiagram.sty1294
1 files changed, 1294 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/modiagram/modiagram.sty b/Master/texmf-dist/tex/latex/modiagram/modiagram.sty
new file mode 100644
index 00000000000..d3db03f942b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/modiagram/modiagram.sty
@@ -0,0 +1,1294 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% --------------------------------------------------------------------------- %
+% - MOdiagram - modiagram.sty - %
+% - easy creation of molecular orbital diagrams - %
+% --------------------------------------------------------------------------- %
+% - Clemens Niederberger - %
+% - 2011/09/25 - %
+% --------------------------------------------------------------------------- %
+% - http://www.mychemistry.eu/ - %
+% - contact@mychemistry.eu - %
+% --------------------------------------------------------------------------- %
+% - If you have any ideas, questions, suggestions or bugs to report, please - %
+% - feel free to contact me. - %
+% --------------------------------------------------------------------------- %
+% - Copyright 2011 Clemens Niederberger - %
+% - - %
+% - This work may be distributed and/or modified under the - %
+% - conditions of the LaTeX Project Public License, either version 1.3 - %
+% - of this license or (at your option) any later version. - %
+% - The latest version of this license is in - %
+% - http://www.latex-project.org/lppl.txt - %
+% - and version 1.3 or later is part of all distributions of LaTeX - %
+% - version 2005/12/01 or later. - %
+% - - %
+% - This work has the LPPL maintenance status `maintained'. - %
+% - - %
+% - The Current Maintainer of this work is Clemens Niederberger. - %
+% - - %
+% - This work consists of the files modiagram.sty, modiagram_doc_de.tex, - %
+% - modiagram_doc_de.tex, README - %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\RequirePackage{ expl3 , xparse , l3keys2e , tikz , textgreek , amsmath }
+\usetikzlibrary{calc,arrows}
+\ProvidesExplPackage {modiagram} {2011/09/25} {0.1} {easy creation of molecular orbital diagrams}
+
+% --------------------------------------------------------------------------- %
+% error messages
+\msg_set:nnn { MOdiagram } { missing-atom }
+ {
+ You~need~to~specify~the~left~and~right~atom~first~before~you~can~use~
+ \token_to_str:N \molecule \c_space_tl \msg_line_context: .
+ }
+
+\msg_set:nnn { MOdiagram } { missing-AO }
+ {
+ You~need~to~specify~both~#2~AOs~first~before~you~can~use~
+ #1~ \msg_line_context: .
+ }
+
+% --------------------------------------------------------------------------- %
+% main environment
+\NewDocumentEnvironment { MOdiagram } { o g }
+ {
+ \dim_gzero:N \g_MOdiagram_min_energy_dim
+ \dim_gzero:N \g_MOdiagram_max_energy_dim
+ \IfNoValueF { #1 } { \keys_set:nn { MOdiagram / diagram } { #1 } }
+ \MOdiagram_set_labels:
+ \MOdiagram_tikzpicture:n { }
+ }
+ {
+ \bool_if:NT \l_MOdiagram_names_bool
+ {
+ \MOdiagram_node:n { below }
+ at
+ (
+ \l_MOdiagram_left_atom_position_dim ,
+ \g_MOdiagram_min_energy_dim - 1cm
+ )
+ { \smash[b] { \tl_use:N \l_MOdiagram_atom_left_name_tl } } ;
+ \MOdiagram_node:n { below }
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \g_MOdiagram_min_energy_dim - 1cm
+ )
+ { \smash[b] { \tl_use:N \l_MOdiagram_molecule_name_tl } } ;
+ \MOdiagram_node:n { below }
+ at
+ (
+ \l_MOdiagram_left_atom_position_dim
+ + \l_MOdiagram_inter_atom_distance_dim ,
+ \g_MOdiagram_min_energy_dim - 1cm
+ )
+ { \smash[b] { \tl_use:N \l_MOdiagram_atom_right_name_tl } } ;
+ }
+ \endtikzpicture
+ }
+
+\bool_new:N \l_MOdiagram_AO_square_bool
+\bool_new:N \l_MOdiagram_AO_round_bool
+\bool_new:N \l_MOdiagram_AO_fancy_bool
+\bool_new:N \l_MOdiagram_AO_labels_bool
+\bool_new:N \l_MOdiagram_names_bool
+
+\tl_new:N \l_MOdiagram_lines_tl
+\tl_set:Nn \l_MOdiagram_lines_tl { dotted }
+
+\tl_new:N \l_MOdiagram_orbital_label_fontsize_tl
+\tl_new:N \l_MOdiagram_orbital_label_style_tl
+
+\dim_new:N \l_MOdiagram_AO_width_dim
+\dim_set:Nn \l_MOdiagram_AO_width_dim { 10pt }
+
+\dim_new:N \l_MOdiagram_left_atom_position_dim
+\dim_set:Nn \l_MOdiagram_left_atom_position_dim { 1cm }
+\dim_new:N \l_MOdiagram_inter_atom_distance_dim
+\dim_set:Nn \l_MOdiagram_inter_atom_distance_dim { 4cm }
+\dim_new:N \l_MOdiagram_molecule_position_dim
+
+\dim_new:N \g_MOdiagram_min_energy_dim
+\dim_new:N \g_MOdiagram_max_energy_dim
+
+\cs_new_nopar:Npn \MOdiagram_energy_range:N #1
+ {
+ \dim_set:Nn \l_tmpa_dim { #1 }
+ \dim_compare:nT { \l_tmpa_dim < \g_MOdiagram_min_energy_dim }
+ { \dim_gset_eq:NN \g_MOdiagram_min_energy_dim \l_tmpa_dim }
+ \dim_compare:nT { \l_tmpa_dim > \g_MOdiagram_max_energy_dim }
+ { \dim_gset_eq:NN \g_MOdiagram_max_energy_dim \l_tmpa_dim }
+ }
+\cs_generate_variant:Nn \MOdiagram_energy_range:N { n }
+
+\cs_new_nopar:Npn \MOdiagram_molecule_position:n #1
+ {
+ \fp_set_from_dim:Nn \l_tmpa_tl { #1 }
+ \fp_mul:Nn \l_tmpa_tl { .5 }
+ \dim_set:Nn \l_MOdiagram_molecule_position_dim
+ { \fp_to_dim:N \l_tmpa_tl + \l_MOdiagram_left_atom_position_dim }
+ }
+\cs_generate_variant:Nn \MOdiagram_molecule_position:n { f }
+
+\MOdiagram_molecule_position:f
+ { \dim_use:N \l_MOdiagram_inter_atom_distance_dim }
+
+\keys_define:nn { MOdiagram / diagram }
+ {
+ style .choice: ,
+ style / plain .code:n =
+ {
+ \bool_set_false:N \l_MOdiagram_AO_square_bool
+ \bool_set_false:N \l_MOdiagram_AO_round_bool
+ \bool_set_false:N \l_MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l_MOdiagram_lines_tl { dotted }
+ } ,
+ style / square .code:n =
+ {
+ \bool_set_true:N \l_MOdiagram_AO_square_bool
+ \bool_set_false:N \l_MOdiagram_AO_round_bool
+ \bool_set_false:N \l_MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l_MOdiagram_lines_tl { gray }
+ } ,
+ style / round .code:n =
+ {
+ \bool_set_true:N \l_MOdiagram_AO_square_bool
+ \bool_set_true:N \l_MOdiagram_AO_round_bool
+ \bool_set_false:N \l_MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l_MOdiagram_lines_tl { gray }
+ } ,
+ style / fancy .code:n =
+ {
+ \bool_set_true:N \l_MOdiagram_AO_square_bool
+ \bool_set_true:N \l_MOdiagram_AO_round_bool
+ \bool_set_true:N \l_MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l_MOdiagram_lines_tl { densely~dashed }
+ } ,
+ lines .tl_set:N = \l_MOdiagram_lines_tl ,
+ distance .code:n =
+ {
+ \dim_set:Nn \l_MOdiagram_inter_atom_distance_dim { #1 }
+ \MOdiagram_molecule_position:n { #1 }
+ } ,
+ AO-width .tl_set:N = \l_MOdiagram_AO_width_dim ,
+ labels .bool_set:N = \l_MOdiagram_AO_labels_bool ,
+ names .bool_set:N = \l_MOdiagram_names_bool ,
+ labels-fs .tl_set:N = \l_MOdiagram_orbital_label_fontsize_tl ,
+ labels-style .tl_set:N = \l_MOdiagram_orbital_label_style_tl
+ }
+
+% --------------------------------------------------------------------------- %
+% setup command
+\NewDocumentCommand \MOsetup { m }
+ { \keys_set:nn { MOdiagram / diagram } { #1 } \tex_unskip:D }
+
+% --------------------------------------------------------------------------- %
+% draw AOs
+\tl_new:N \l_MOdiagram_atom_left_name_tl
+\tl_new:N \l_MOdiagram_atom_right_name_tl
+
+\bool_new:N \l_MOdiagram_left_atom_placed_bool
+\bool_set_false:N \l_MOdiagram_left_atom_placed_bool
+\bool_new:N \l_MOdiagram_right_atom_placed_bool
+\bool_set_false:N \l_MOdiagram_right_atom_placed_bool
+
+\NewDocumentCommand \atom { o m m }
+ {
+ \MOdiagram_atom_disable:
+ \keys_set:nn { MOdiagram / atom } { position = #2 }
+ \keys_set:nn { MOdiagram / atom } { #3 }
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \bool_set_true:N \l_MOdiagram_left_atom_placed_bool }
+ { \bool_set_true:N \l_MOdiagram_right_atom_placed_bool }
+ \IfNoValueF { #1 }
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \tl_set:Nn \l_MOdiagram_atom_left_name_tl { #1 } }
+ { \tl_set:Nn \l_MOdiagram_atom_right_name_tl { #1 } }
+ }
+ \MOdiagram_one_s:
+ \MOdiagram_two_s:
+ \MOdiagram_two_p:
+% \MOdiagram_three_s:
+% \MOdiagram_three_p:
+% \MOdiagram_four_s:
+ }
+
+\bool_new:N \l_MOdiagram_atom_left_bool
+
+\keys_define:nn { MOdiagram / atom }
+ {
+ position .choice: ,
+ position / left .code:n =
+ { \bool_set_true:N \l_MOdiagram_atom_left_bool } ,
+ position / right .code:n =
+ { \bool_set_false:N \l_MOdiagram_atom_left_bool }
+ }
+
+\dim_new:N \l_MOdiagram_atom_xshift_dim
+
+\keys_define:nn { MOdiagram / atom }
+ {
+ 1s .code:n = { \MOdiagram_one_s_set:n #1 \q_stop } ,
+ 2s .code:n = { \MOdiagram_two_s_set:n #1 \q_stop } ,
+ 2p .code:n = { \MOdiagram_two_p_set:n #1 \q_stop } ,
+ color .code:n = { \MOdiagram_electron_color_set:n { #1 } } ,
+ label .code:n = { \MOdiagram_orbital_label_set:n { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% 1s orbital
+\dim_new:N \l_MOdiagram_atom_one_s_dim
+\dim_new:N \l_MOdiagram_atom_left_one_s_dim
+\dim_new:N \l_MOdiagram_atom_right_one_s_dim
+
+\tl_new:N \l_MOdiagram_AO_one_s_electron_tl
+
+\bool_new:N \l_MOdiagram_atom_one_s_bool
+\bool_new:N \l_MOdiagram_one_s_left_bool
+\bool_set_false:N \l_MOdiagram_one_s_left_bool
+\bool_new:N \l_MOdiagram_one_s_right_bool
+\bool_set_false:N \l_MOdiagram_one_s_right_bool
+
+\cs_new_nopar:Npn \MOdiagram_one_s_set:n #1;#2 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_atom_one_s_bool
+ \dim_set:Nn \l_MOdiagram_atom_one_s_dim { #1 cm }
+ \tl_set:Nn \l_MOdiagram_AO_one_s_electron_tl { #2 }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_one_s:
+ {
+ \bool_if:NT \l_MOdiagram_atom_one_s_bool
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_xshift_dim
+ \l_MOdiagram_left_atom_position_dim
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_left_one_s_dim
+ \l_MOdiagram_atom_one_s_dim
+ \bool_set_true:N \l_MOdiagram_one_s_left_bool
+ }
+ {
+ \dim_set:Nn \l_MOdiagram_atom_xshift_dim
+ {
+ \l_MOdiagram_left_atom_position_dim
+ + \l_MOdiagram_inter_atom_distance_dim
+ }
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_right_one_s_dim
+ \l_MOdiagram_atom_one_s_dim
+ \bool_set_true:N \l_MOdiagram_one_s_right_bool
+ }
+ \MOdiagram_energy_range:N \l_MOdiagram_atom_one_s_dim
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1s
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at ( \l_MOdiagram_atom_xshift_dim , \l_MOdiagram_atom_one_s_dim )
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_electron_color:n { 1sleft } }
+ { \MOdiagram_get_electron_color:n { 1sright } }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_one_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_orbital_label:n { 1s left } }
+ { \MOdiagram_get_orbital_label:n { 1s right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2s orbital
+\dim_new:N \l_MOdiagram_atom_two_s_dim
+\dim_new:N \l_MOdiagram_atom_left_two_s_dim
+\dim_new:N \l_MOdiagram_atom_right_two_s_dim
+
+\tl_new:N \l_MOdiagram_AO_two_s_electron_tl
+
+\bool_new:N \l_MOdiagram_atom_two_s_bool
+\bool_new:N \l_MOdiagram_two_s_left_bool
+\bool_set_false:N \l_MOdiagram_two_s_left_bool
+\bool_new:N \l_MOdiagram_two_s_right_bool
+\bool_set_false:N \l_MOdiagram_two_s_right_bool
+
+\cs_new_nopar:Npn \MOdiagram_two_s_set:n #1;#2 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_atom_two_s_bool
+ \dim_set:Nn \l_MOdiagram_atom_two_s_dim { #1 cm }
+ \tl_set:Nn \l_MOdiagram_AO_two_s_electron_tl { #2 }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_two_s:
+ {
+ \bool_if:NT \l_MOdiagram_atom_two_s_bool
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_xshift_dim
+ \l_MOdiagram_left_atom_position_dim
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_left_two_s_dim
+ \l_MOdiagram_atom_two_s_dim
+ \bool_set_true:N \l_MOdiagram_two_s_left_bool
+ }
+ {
+ \dim_set:Nn \l_MOdiagram_atom_xshift_dim
+ {
+ \l_MOdiagram_left_atom_position_dim
+ + \l_MOdiagram_inter_atom_distance_dim
+ }
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_right_two_s_dim
+ \l_MOdiagram_atom_two_s_dim
+ \bool_set_true:N \l_MOdiagram_two_s_right_bool
+ }
+ \MOdiagram_energy_range:N \l_MOdiagram_atom_two_s_dim
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2s
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at ( \l_MOdiagram_atom_xshift_dim , \l_MOdiagram_atom_two_s_dim )
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_electron_color:n { 2sleft } }
+ { \MOdiagram_get_electron_color:n { 2sright } }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_two_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_orbital_label:n { 2s left } }
+ { \MOdiagram_get_orbital_label:n { 2s right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2p orbital
+\dim_new:N \l_MOdiagram_atom_two_p_dim
+\dim_new:N \l_MOdiagram_atom_left_two_p_dim
+\dim_new:N \l_MOdiagram_atom_right_two_p_dim
+
+\dim_new:N \l_MOdiagram_atom_px_shift_dim
+\dim_new:N \l_MOdiagram_atom_py_shift_dim
+\dim_new:N \l_MOdiagram_atom_pz_shift_dim
+
+\tl_new:N \l_MOdiagram_AO_two_px_electron_tl
+\tl_new:N \l_MOdiagram_AO_two_py_electron_tl
+\tl_new:N \l_MOdiagram_AO_two_pz_electron_tl
+
+\bool_new:N \l_MOdiagram_atom_two_p_bool
+\bool_new:N \l_MOdiagram_two_p_left_bool
+\bool_set_false:N \l_MOdiagram_two_p_left_bool
+\bool_new:N \l_MOdiagram_two_p_right_bool
+\bool_set_false:N \l_MOdiagram_two_p_right_bool
+
+\cs_new_nopar:Npn \MOdiagram_two_p_set:n #1;#2,#3,#4 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_atom_two_p_bool
+ \dim_set:Nn \l_MOdiagram_atom_two_p_dim { #1 cm }
+ \tl_set:Nn \l_MOdiagram_AO_two_px_electron_tl { #2 }
+ \tl_set:Nn \l_MOdiagram_AO_two_py_electron_tl { #3 }
+ \tl_set:Nn \l_MOdiagram_AO_two_pz_electron_tl { #4 }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_p_orbitals_shift:nnn #1#2#3
+ {
+ \fp_set_from_dim:Nn \l_tmpa_tl { \l_MOdiagram_AO_width_dim }
+ {
+ \fp_mul:Nn \l_tmpa_tl { #1 }
+ \dim_gset:Nn \l_MOdiagram_atom_px_shift_dim { \fp_to_dim:N \l_tmpa_tl }
+ }
+ {
+ \fp_mul:Nn \l_tmpa_tl { #2 }
+ \dim_gset:Nn \l_MOdiagram_atom_py_shift_dim { \fp_to_dim:N \l_tmpa_tl }
+ }
+ {
+ \fp_mul:Nn \l_tmpa_tl { #3 }
+ \dim_gset:Nn \l_MOdiagram_atom_pz_shift_dim { \fp_to_dim:N \l_tmpa_tl }
+ }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_two_p:
+ {
+ \bool_if:NT \l_MOdiagram_atom_two_p_bool
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_xshift_dim
+ \l_MOdiagram_left_atom_position_dim
+ \MOdiagram_p_orbitals_shift:nnn { -4 } { -2 } { 0 }
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_left_two_p_dim
+ \l_MOdiagram_atom_two_p_dim
+ \dim_set_eq:NN
+ \l_energy_axis_dim
+ \l_MOdiagram_atom_px_shift_dim
+ \bool_set_true:N \l_MOdiagram_two_p_left_bool
+ }
+ {
+ \dim_set:Nn \l_MOdiagram_atom_xshift_dim
+ {
+ \l_MOdiagram_left_atom_position_dim
+ + \l_MOdiagram_inter_atom_distance_dim
+ }
+ \MOdiagram_p_orbitals_shift:nnn { 0 } { 2 } { 4 }
+ \dim_set_eq:NN
+ \l_MOdiagram_atom_right_two_p_dim
+ \l_MOdiagram_atom_two_p_dim
+ \bool_set_true:N \l_MOdiagram_two_p_right_bool
+ }
+ \MOdiagram_energy_range:N \l_MOdiagram_atom_two_p_dim
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2pz
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l_MOdiagram_atom_xshift_dim + \l_MOdiagram_atom_pz_shift_dim ,
+ \l_MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_electron_color:n { 2pz left } }
+ { \MOdiagram_get_electron_color:n { 2pz right } }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_two_pz_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_orbital_label:n { 2pz left } }
+ { \MOdiagram_get_orbital_label:n { 2pz right } }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2py
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l_MOdiagram_atom_xshift_dim + \l_MOdiagram_atom_py_shift_dim ,
+ \l_MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_electron_color:n { 2py left } }
+ { \MOdiagram_get_electron_color:n { 2py right } }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_two_py_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_orbital_label:n { 2py left } }
+ { \MOdiagram_get_orbital_label:n { 2py right } }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2px
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l_MOdiagram_atom_xshift_dim + \l_MOdiagram_atom_px_shift_dim ,
+ \l_MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_electron_color:n { 2px left } }
+ { \MOdiagram_get_electron_color:n { 2px right } }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_two_px_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \bool_if:NTF \l_MOdiagram_atom_left_bool
+ { \MOdiagram_get_orbital_label:n { 2px left } }
+ { \MOdiagram_get_orbital_label:n { 2px right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% draw MOs
+\tl_new:N \l_MOdiagram_molecule_name_tl
+
+\NewDocumentCommand \molecule { o m }
+ {
+ \bool_if:nTF
+ {
+ \l_MOdiagram_left_atom_placed_bool
+ &&
+ \l_MOdiagram_right_atom_placed_bool
+ }
+ {
+ \MOdiagram_molecule_disable:
+ \keys_set:nn { MOdiagram / molecule } { #2 }
+ \IfNoValueF { #1 }
+ { \tl_set:Nn \l_MOdiagram_molecule_name_tl { #1 } }
+ \MOdiagram_one_mo_s:
+ \MOdiagram_two_mo_s:
+ \MOdiagram_two_mo_p:
+% \MOdiagram_three_mo_s:
+% \MOdiagram_three_mo_p:
+% \MOdiagram_four_mo_s:
+ }
+ { \msg_error:nn { MOdiagram } { missing-atom } }
+ }
+
+\keys_define:nn { MOdiagram / molecule }
+ {
+ 1sMO .code:n = { \MOdiagram_one_mo_s_set:n #1 \q_stop } ,
+ 2sMO .code:n = { \MOdiagram_two_mo_s_set:n #1 \q_stop } ,
+ 2pMO .code:n = { \MOdiagram_two_mo_p_set:n #1 \q_stop } ,
+ color .code:n = { \MOdiagram_electron_color_set:n { #1 } } ,
+ label .code:n = { \MOdiagram_orbital_label_set:n { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% 1sigma orbitals
+\dim_new:N \l_MOdiagram_molecule_one_sigma_dim
+\dim_new:N \l_MOdiagram_molecule_one_sigmas_dim
+
+\tl_new:N \l_MOdiagram_MO_one_sigma_s_electron_tl
+\tl_new:N \l_MOdiagram_MO_one_sigmas_s_electron_tl
+\bool_new:N \l_MOdiagram_molecule_one_mo_s_bool
+
+\cs_new_nopar:Npn \MOdiagram_one_mo_s_set:n #1;#2,#3 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_molecule_one_mo_s_bool
+ \tl_set:Nn \l_MOdiagram_MO_one_sigma_s_electron_tl { #2 }
+ \tl_set:Nn \l_MOdiagram_MO_one_sigmas_s_electron_tl { #3 }
+ \dim_set:Nn \l_MOdiagram_molecule_one_sigma_dim { #1 cm }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_one_mo_s:
+ {
+ \bool_if:NT \l_MOdiagram_molecule_one_mo_s_bool
+ {
+ \bool_if:nF
+ { \l_MOdiagram_one_s_left_bool && \l_MOdiagram_one_s_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 1sMO } { 1s } }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_left_one_s_dim
+ - \l_MOdiagram_molecule_one_sigma_dim
+ }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_right_one_s_dim
+ + \l_MOdiagram_molecule_one_sigma_dim
+ }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1sigma)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_left_one_s_dim
+ - \l_MOdiagram_molecule_one_sigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 1sigma }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_one_sigma_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 1sigma }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1sigma*)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_right_one_s_dim
+ + \l_MOdiagram_molecule_one_sigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 1sigma* }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_one_sigmas_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 1sigma* }
+ \MOdiagram_draw:f
+ { \l_MOdiagram_lines_tl }
+ (1s left.east) -- (1sigma.west) (1sigma.east) -- (1s right.west)
+ (1s left.east) -- (1sigma*.west) (1sigma*.east) -- (1s right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2sigma orbitals
+\dim_new:N \l_MOdiagram_molecule_two_sigma_dim
+\dim_new:N \l_MOdiagram_molecule_two_sigmas_dim
+
+\tl_new:N \l_MOdiagram_MO_two_sigma_s_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_sigmas_s_electron_tl
+\bool_new:N \l_MOdiagram_molecule_two_mo_s_bool
+
+\cs_new_nopar:Npn \MOdiagram_two_mo_s_set:n #1;#2,#3 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_molecule_two_mo_s_bool
+ \tl_set:Nn \l_MOdiagram_MO_two_sigma_s_electron_tl { #2 }
+ \tl_set:Nn \l_MOdiagram_MO_two_sigmas_s_electron_tl { #3 }
+ \dim_set:Nn \l_MOdiagram_molecule_two_sigma_dim { #1 cm }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_two_mo_s:
+ {
+ \bool_if:NT \l_MOdiagram_molecule_two_mo_s_bool
+ {
+ \bool_if:nF
+ { \l_MOdiagram_two_s_left_bool && \l_MOdiagram_two_s_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 2sMO } { 2s } }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_left_two_s_dim
+ - \l_MOdiagram_molecule_two_sigma_dim
+ }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_right_two_s_dim
+ + \l_MOdiagram_molecule_two_sigma_dim
+ }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2sigma)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_left_two_s_dim
+ - \l_MOdiagram_molecule_two_sigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2sigma }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_sigma_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2sigma }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2sigma*)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_right_two_s_dim
+ + \l_MOdiagram_molecule_two_sigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2sigma* }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_sigmas_s_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2sigma* }
+ \MOdiagram_draw:f
+ { \l_MOdiagram_lines_tl }
+ (2s left.east) -- (2sigma.west) (2sigma.east) -- (2s right.west)
+ (2s left.east) -- (2sigma*.west) (2sigma*.east) -- (2s right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2sigma orbitals
+\dim_new:N \l_MOdiagram_molecule_two_psigma_dim
+\dim_new:N \l_MOdiagram_molecule_two_ppi_dim
+
+\tl_new:N \l_MOdiagram_MO_two_sigma_p_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_sigmas_p_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_piy_p_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_piys_p_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_piz_p_electron_tl
+\tl_new:N \l_MOdiagram_MO_two_pizs_p_electron_tl
+
+\bool_new:N \l_MOdiagram_molecule_two_mo_p_bool
+
+\cs_new_nopar:Npn \MOdiagram_two_mo_p_set:n #1,#2;#3,#4,#5,#6,#7,#8 \q_stop
+ {
+ \bool_set_true:N \l_MOdiagram_molecule_two_mo_p_bool
+ \tl_set:Nn \l_MOdiagram_MO_two_sigma_p_electron_tl { #3 }
+ \tl_set:Nn \l_MOdiagram_MO_two_sigmas_p_electron_tl { #8 }
+ \tl_set:Nn \l_MOdiagram_MO_two_piy_p_electron_tl { #4 }
+ \tl_set:Nn \l_MOdiagram_MO_two_piys_p_electron_tl { #6 }
+ \tl_set:Nn \l_MOdiagram_MO_two_piz_p_electron_tl { #5 }
+ \tl_set:Nn \l_MOdiagram_MO_two_pizs_p_electron_tl { #7 }
+ \dim_set:Nn \l_MOdiagram_molecule_two_psigma_dim { #1 cm }
+ \dim_set:Nn \l_MOdiagram_molecule_two_ppi_dim { #2 cm }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_two_mo_p:
+ {
+ \bool_if:NT \l_MOdiagram_molecule_two_mo_p_bool
+ {
+ \bool_if:nF
+ { \l_MOdiagram_two_p_left_bool && \l_MOdiagram_two_p_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 2pMO } { 2p } }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_left_two_p_dim
+ - \l_MOdiagram_molecule_two_psigma_dim
+ }
+ \MOdiagram_energy_range:n
+ {
+ \l_MOdiagram_atom_right_two_p_dim
+ + \l_MOdiagram_molecule_two_psigma_dim
+ }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2psigma)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_left_two_p_dim
+ - \l_MOdiagram_molecule_two_psigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2psigma }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_sigma_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2psigma }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2psigma*)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim ,
+ \l_MOdiagram_atom_right_two_p_dim
+ + \l_MOdiagram_molecule_two_psigma_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2psigma* }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_sigmas_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2psigma* }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piy)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim - \l_MOdiagram_AO_width_dim ,
+ \l_MOdiagram_atom_left_two_p_dim
+ - \l_MOdiagram_molecule_two_ppi_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2piy }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_piy_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2piy }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piy*)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim - \l_MOdiagram_AO_width_dim ,
+ \l_MOdiagram_atom_right_two_p_dim
+ + \l_MOdiagram_molecule_two_ppi_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2piy* }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_piys_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2piy* }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piz)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim + \l_MOdiagram_AO_width_dim ,
+ \l_MOdiagram_atom_left_two_p_dim
+ - \l_MOdiagram_molecule_two_ppi_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2piz }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_piz_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2piz }
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piz*)
+ at
+ (
+ \l_MOdiagram_molecule_position_dim + \l_MOdiagram_AO_width_dim ,
+ \l_MOdiagram_atom_right_two_p_dim
+ + \l_MOdiagram_molecule_two_ppi_dim
+ )
+ {
+ \MOdiagram_get_electron_color:n { 2piz* }
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_MO_two_pizs_p_electron_tl }
+ { \tl_use:N \l_tmpb_tl }
+ } ;
+ \MOdiagram_get_orbital_label:n { 2piz* }
+ \MOdiagram_draw:f
+ { \l_MOdiagram_lines_tl }
+ (2pz left.east) -- (2psigma.west) (2psigma.east) -- (2px right.west)
+ (2pz left.east) -- (2psigma*.west) (2psigma*.east) -- (2px right.west)
+ (2pz left.east) -- (2piy.west) (2piz.east) -- (2px right.west)
+ (2pz left.east) -- (2piy*.west) (2piz*.east) -- (2px right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% draw actual AO / MO
+\tl_new:N \l_MOdiagram_electron_color_tl
+
+\cs_new_nopar:Npn \MOdiagram_AO:nn #1#2
+ {
+ \group_begin:
+ \tl_set:Nn \l_MOdiagram_electron_color_tl { #2 }
+ \tikzpicture
+ \bool_if:NT \l_MOdiagram_AO_fancy_bool
+ {
+ \draw (0,0) -- ++(-.5*\l_MOdiagram_AO_width_dim,0) ;
+ \draw (2pt+\l_MOdiagram_AO_width_dim,0)
+ -- ++(.5*\l_MOdiagram_AO_width_dim,0) ;
+ }
+ \MOdiagram_node:x
+ {
+ inner~sep = 0 ,
+ \bool_if:NT \l_MOdiagram_AO_square_bool { draw } ,
+ minimum~size =
+ \bool_if:NTF \l_MOdiagram_AO_square_bool
+ { 2pt+\l_MOdiagram_AO_width_dim } { 0 } ,
+ \bool_if:NT \l_MOdiagram_AO_round_bool
+ { rounded~corners=2pt }
+ }
+ at (.5*\l_MOdiagram_AO_width_dim+1pt,0)
+ {
+ \tikz
+ {
+ \bool_if:NF \l_MOdiagram_AO_square_bool
+ { \draw (0,0) -- ++(\l_MOdiagram_AO_width_dim,0) ; }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \tl_remove_all:Nn \l_tmpa_tl { ~ }
+ \prg_case_str:onn { \l_tmpa_tl }
+ {
+ { up }
+ {
+ \MOdiagram_draw:f
+ { -left~to,semithick , \l_MOdiagram_electron_color_tl }
+ (.4*\l_MOdiagram_AO_width_dim,-.4*\l_MOdiagram_AO_width_dim)
+ -- ++(0,.8*\l_MOdiagram_AO_width_dim) ;
+ }
+ { down }
+ {
+ \MOdiagram_draw:f
+ { -left~to,semithick , \l_MOdiagram_electron_color_tl }
+ (.6*\l_MOdiagram_AO_width_dim,.4*\l_MOdiagram_AO_width_dim)
+ -- ++(0,-.8*\l_MOdiagram_AO_width_dim) ;
+ }
+ { pair }
+ {
+ \MOdiagram_draw:f
+ { -left~to,semithick , \l_MOdiagram_electron_color_tl }
+ (.4*\l_MOdiagram_AO_width_dim,-.4*\l_MOdiagram_AO_width_dim)
+ -- ++(0,.8*\l_MOdiagram_AO_width_dim) ;
+ \MOdiagram_draw:f
+ { -left~to,semithick , \l_MOdiagram_electron_color_tl }
+ (.6*\l_MOdiagram_AO_width_dim,.4*\l_MOdiagram_AO_width_dim)
+ -- ++(0,-.8*\l_MOdiagram_AO_width_dim) ;
+ }
+ }
+ {}
+ }
+ } ;
+ \endtikzpicture
+ \group_end:
+ }
+\cs_generate_variant:Nn \MOdiagram_AO:nn { ff }
+
+% -------------------------------------------------------------------------- %
+% per default disable all AOs / MOs
+\cs_new_nopar:Npn \MOdiagram_atom_disable:
+ {
+ \bool_set_false:N \l_MOdiagram_atom_one_s_bool
+ \bool_set_false:N \l_MOdiagram_atom_two_s_bool
+ \bool_set_false:N \l_MOdiagram_atom_two_p_bool
+% \bool_set_false:N \l_MOdiagram_atom_three_s_bool
+% \bool_set_false:N \l_MOdiagram_atom_three_p_bool
+ }
+
+\cs_new_nopar:Npn \MOdiagram_molecule_disable:
+ {
+ \bool_set_false:N \l_MOdiagram_molecule_one_mo_s_bool
+ }
+
+% --------------------------------------------------------------------------- %
+% arbitrary placement of AOs / MOs
+\dim_new:N \l_MOdiagram_AO_dim % y
+\dim_new:N \l_MOdiagram_AO_position_dim % x
+
+\dim_new:N \l_MOdiagram_AO_px_shift_dim
+\dim_new:N \l_MOdiagram_AO_py_shift_dim
+\dim_new:N \l_MOdiagram_AO_pz_shift_dim
+
+\tl_new:N \l_MOdiagram_AO_px_electron_tl
+\tl_new:N \l_MOdiagram_AO_py_electron_tl
+\tl_new:N \l_MOdiagram_AO_pz_electron_tl
+
+\tl_new:N \l_MOdiagram_AO_name_tl
+
+\bool_new:N \l_MOdiagram_AO_p_bool
+\bool_new:N \l_MOdiagram_AO_left_bool
+
+\cs_new_nopar:Npn \MOdiagram_AO_s_set:n #1;#2 \q_stop
+ {
+ \dim_set:Nn \l_MOdiagram_AO_dim { #1 cm }
+ \tl_set:Nn \l_MOdiagram_AO_px_electron_tl { #2 }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_AO_p_set:n #1;#2,#3,#4 \q_stop
+ {
+ \dim_set:Nn \l_MOdiagram_AO_dim { #1 cm }
+ \tl_set:Nn \l_MOdiagram_AO_px_electron_tl { #2 }
+ \tl_set:Nn \l_MOdiagram_AO_py_electron_tl { #3 }
+ \tl_set:Nn \l_MOdiagram_AO_pz_electron_tl { #4 }
+ }
+
+\keys_define:nn { MOdiagram / AO }
+ {
+ type .choice: ,
+ type / s .code:n = { \bool_set_false:N \l_MOdiagram_AO_p_bool } ,
+ type / p .code:n = { \bool_set_true:N \l_MOdiagram_AO_p_bool }
+ }
+
+% AO[<name>](<x-coord>){<type>}{<AO-spec>}
+\NewDocumentCommand \AO { o D(){0cm} m m }
+ {
+ \IfNoValueF { #1 } { \tl_set:Nn \l_MOdiagram_AO_name_tl { #1 } }
+ \keys_set:nn { MOdiagram / AO } { type = #3 }
+ \bool_if:NTF \l_MOdiagram_AO_p_bool
+ { \MOdiagram_AO_p_set:n #4 \q_stop }
+ { \MOdiagram_AO_s_set:n #4 \q_stop }
+ \dim_set:Nn \l_MOdiagram_AO_position_dim { #2 }
+% \fp_set_from_dim:Nn \l_tmpa_tl { \l_MOdiagram_AO_width_dim }
+ \MOdiagram_p_orbitals_shift:nnn { 0 } { 2 } { 4 }
+ \MOdiagram_energy_range:N \l_MOdiagram_AO_dim
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (
+ \tl_use:N \l_MOdiagram_AO_name_tl
+ \bool_if:NT \l_MOdiagram_AO_p_bool { x }
+ )
+ at
+ (
+ \l_MOdiagram_AO_position_dim + \l_MOdiagram_atom_px_shift_dim ,
+ \l_MOdiagram_AO_dim
+ )
+ {
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_px_electron_tl }
+ { }
+ } ;
+ % TODO get & set label
+ \bool_if:NT \l_MOdiagram_AO_p_bool
+ {
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ ( \tl_use:N \l_MOdiagram_AO_name_tl y )
+ at
+ (
+ \l_MOdiagram_AO_position_dim + \l_MOdiagram_atom_py_shift_dim ,
+ \l_MOdiagram_AO_dim
+ )
+ {
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_py_electron_tl }
+ { }
+ } ;
+ % TODO get & set label
+ \MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ ( \tl_use:N \l_MOdiagram_AO_name_tl z )
+ at
+ (
+ \l_MOdiagram_AO_position_dim + \l_MOdiagram_atom_pz_shift_dim ,
+ \l_MOdiagram_AO_dim
+ )
+ {
+ \MOdiagram_AO:ff
+ { \tl_use:N \l_MOdiagram_AO_pz_electron_tl }
+ { }
+ } ;
+ % TODO get & set label
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+\NewDocumentCommand \AOinline { o m }
+ {
+ \group_begin:
+ \IfNoValueTF { #1 }
+ { ~ \MOsetup { style=square,AO-width=8pt } }
+ { ~ \MOsetup { style=square,AO-width=8pt , #1 } }
+ \begin{MOdiagram}
+ \AO{s}{0;#2}
+ \end{MOdiagram}
+ \group_end:
+ }
+
+% --------------------------------------------------------------------------- %
+% connect arbitrary AOs / MOs
+\NewDocumentCommand \connect { m }
+ {
+ \clist_map_variable:nNn { #1 } \l_tmpa_tl
+ {
+ \tl_remove_all:Nn \l_tmpa_tl { ~ }
+ \tl_if_blank:VF \l_tmpa_tl
+ {
+ \MOdiagram_detect_nodes:x { \l_tmpa_tl }
+ \tl_if_in:NnF \l_MOdiagram_node_A_tl { . }
+ { \tl_put_right:Nn \l_MOdiagram_node_A_tl { . east } }
+ \tl_if_in:NnF \l_MOdiagram_node_B_tl { . }
+ { \tl_put_right:Nn \l_MOdiagram_node_B_tl { . west } }
+ \MOdiagram_draw_connection:xxx
+ { \tl_use:N \l_MOdiagram_lines_tl }
+ { \tl_use:N \l_MOdiagram_node_A_tl }
+ { \tl_use:N \l_MOdiagram_node_B_tl }
+ }
+ }
+ }
+
+\NewDocumentCommand \MOdiagram_detect_nodes:n { > { \SplitArgument { 1 } { & } } m }
+ { \MOdiagram_detect_nodes_aux_i:nn #1 }
+\cs_generate_variant:Nn \MOdiagram_detect_nodes:n { x }
+
+\cs_new_nopar:Npn \MOdiagram_detect_nodes_aux_i:nn #1#2
+ {
+ \tl_set:Nn \l_MOdiagram_node_A_tl { #1 }
+ \tl_set:Nn \l_MOdiagram_node_B_tl { #2 }
+ }
+
+\cs_new_nopar:Npn \MOdiagram_draw_connection:nnn #1#2#3
+ { \draw[#1] (#2) -- (#3) ; }
+\cs_generate_variant:Nn \MOdiagram_draw_connection:nnn { xxx }
+
+% --------------------------------------------------------------------------- %
+% orbital labels
+\prop_new:N \l_MOdiagram_orbital_label_prop
+\tl_set:Nn \l_MOdiagram_orbital_label_fontsize_tl { \small }
+
+\cs_new_nopar:Npn \MOdiagram_orbital_label_set:n #1
+ { \keys_set:nn { MOdiagram / label } { #1 } }
+
+\cs_new_nopar:Npn \MOdiagram_get_orbital_label:n #1
+ {
+ \tl_clear:N \l_tmpa_tl
+ \tl_clear:N \l_tmpb_tl
+ \prop_get:NnNT \l_MOdiagram_orbital_label_prop { #1 } \l_tmpa_tl
+ {
+ \MOdiagram_node:x
+ { below , \tl_use:N \l_MOdiagram_orbital_label_style_tl }
+ at ( #1 . south )
+ {
+ \tl_use:N \l_MOdiagram_orbital_label_fontsize_tl
+ \tl_use:N \l_tmpa_tl
+ } ;
+ }
+ }
+
+\keys_define:nn { MOdiagram / label }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piz* } { #1 } }
+ }
+
+\char_set_catcode_math_subscript:N \@
+\cs_new_nopar:Npn \MOdiagram_set_labels:
+ {
+ \bool_if:NT \l_MOdiagram_AO_labels_bool
+ {
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sleft } { 1s }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sright } { 1s }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sleft } { 2s }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sright } { 2s }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pxleft } { 2p$@x$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pxright } { 2p$@x$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pyleft } { 2p$@y$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pyright } { 2p$@y$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pzleft } { 2p$@z$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2pzright } { 2p$@z$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sigma } { 1\textsigma$@s$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 1sigma* } { 1\textsigma$^*@s$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sigma } { 2\textsigma$@s$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2sigma* } { 2\textsigma$^*@s$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2psigma } { 2\textsigma$@x$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2psigma* } { 2\textsigma$^*@x$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piy } { 2\textpi$@y$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piy* } { 2\textpi$^*@y$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piz } { 2\textpi$@z$ }
+ \prop_put:Nnn \l_MOdiagram_orbital_label_prop { 2piz* } { 2\textpi$^*@z$ }
+ }
+ }
+\char_set_catcode_letter:N \@
+
+% --------------------------------------------------------------------------- %
+% electron colours
+\prop_new:N \l_MOdiagram_electron_color_prop
+
+\cs_new_nopar:Npn \MOdiagram_electron_color_set:n #1
+ { \keys_set:nn { MOdiagram / color } { #1 } }
+
+\cs_new_nopar:Npn \MOdiagram_get_electron_color:n #1
+ {
+ \tl_clear:N \l_tmpa_tl
+ \tl_clear:N \l_tmpb_tl
+ \prop_get:NnNT \l_MOdiagram_electron_color_prop { #1 } \l_tmpa_tl
+ { \tl_set_eq:NN \l_tmpb_tl \l_tmpa_tl }
+ }
+
+\keys_define:nn { MOdiagram / color }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l_MOdiagram_electron_color_prop { 2piz* } { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% energy axis
+\dim_new:N \l_energy_axis_dim
+\dim_set:Nn \l_energy_axis_dim { 0pt }
+
+\tl_new:N \l_MOdiagram_Eaxis_head_tl
+\tl_set:Nn \l_MOdiagram_Eaxis_head_tl { latex }
+\tl_new:N \l_MOdiagram_Eaxis_title_tl
+
+\bool_new:N \l_MOdiagram_Eaxis_title_bool
+\bool_set_false:N \l_MOdiagram_Eaxis_title_bool
+
+\NewDocumentCommand \EnergyAxis { o }
+ {
+ \IfNoValueF { #1 } { \keys_set:nn { MOdiagram / axis } { #1 } }
+ \MOdiagram_draw:f { - \tl_use:N \l_MOdiagram_Eaxis_head_tl }
+ (\l_energy_axis_dim , \g_MOdiagram_min_energy_dim - 1cm )
+ --
+ (\l_energy_axis_dim , \g_MOdiagram_max_energy_dim + 1cm )
+ \bool_if:NT \l_MOdiagram_Eaxis_title_bool
+ { node [ above ] { \tl_use:N \l_MOdiagram_Eaxis_title_tl } }
+ ;
+ }
+
+\keys_define:nn { MOdiagram / axis }
+ {
+ title .code:n =
+ {
+ \bool_set_true:N \l_MOdiagram_Eaxis_title_bool
+ \tl_set:Nn \l_MOdiagram_Eaxis_title_tl { #1 }
+ } ,
+ title .default:n = energy ,
+ head .tl_set:N = \l_MOdiagram_Eaxis_head_tl ,
+ head .default:n = >
+ }
+
+% --------------------------------------------------------------------------- %
+% tikz helper functions
+\cs_new_nopar:Npn \MOdiagram_node:n #1
+ { \node [ #1 ] }
+\cs_generate_variant:Nn \MOdiagram_node:n { f,x }
+
+\cs_new_nopar:Npn \MOdiagram_draw:n #1
+ { \draw [ #1 ] }
+\cs_generate_variant:Nn \MOdiagram_draw:n { f }
+
+\cs_new_nopar:Npn \MOdiagram_tikz:nn #1
+ { \tikz [ #1 ] }
+\cs_generate_variant:Nn \MOdiagram_tikz:nn { fn,xn }
+
+\cs_new_nopar:Npn \MOdiagram_tikzpicture:n #1
+ { \tikzpicture [ #1 ] }
+\cs_generate_variant:Nn \MOdiagram_tikzpicture:n { f }
+
+\tex_endinput:D
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Version history
+2011/09/25 version 0.1 - first upload to CTAN
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% TODO
+- 3s, 3p , 3sMO , 3pMO , 4s , sp3
+- Farbe und Label der \AO setzen können
+- key shift analog zu color und label, mit dem eine horizontale Verschiebung
+ der el möglich ist.
+- energy axis: ticks? at orbital heights? \ No newline at end of file