{"cells":[{"metadata":{},"cell_type":"markdown","source":"**This kernel will be updated in the future.**"},{"metadata":{},"cell_type":"markdown","source":"# Deep Learning of the Theory Behind\n\n**Spoiler:** it will be described mainly from the perspective of organic chemistry and a little bit from the perspective of physics. As the support vector I used videos by Khan Academy, but here is everything and a bit more put in my own words."},{"metadata":{},"cell_type":"markdown","source":"## Basic Principles of NMR\n\nNMR stands for **N**uclear **M**agnetic **R**esonance. In this section I'll cover each of three words and put them together.\n\n**Nuclear.** This word means that the phenomen appears on the level of nuclei of atoms. Let's consider the simplest nucleus all over the periodic table - nucleus of 1H isotope that is nothing more than just a single proton. The proton has a relative mass of nearly 1 and most importantly it has an electrical charge +1e (e ~ 1.6e-19 C).\n\n**Magnetic.** Proton rotates around its own central axis. Thus, a proton is said to have a nuclear spin. Any moving electrical charge is a source of a magnetic field. The orientation of created magnetic field depends on the nuclear spin. We can see analogy to the compass needle here. If nuclear spin equals +1 (nucleus rotates to the right), then the vector of magnetic induction **B** that defines the force of the field is oriented upwards. This vector is reffered to as *magnetic (dipole) moment*. Of course, the negative spin -1 leads to the opposite orientation of both nuclear rotation and direction of magnetic moment.\n\n![Proton Spin](https://images.slideplayer.com/23/6642593/slides/slide_3.jpg)\n\n**Resonance.** This is the effect that allows for determining molecular structures of many chemical compounds. We figured out that proton possesses electrical charge, and because it moves around itself, a magnetic field appears. Now, the nucleus starts to behave like a tiny magnet. Recall that if we have two magnets they can interact. The same is true even for such small magnets. In the wild, they interact with a natural magnetic field of the Earth. But we can put them into stronger magnetic fields generated by special instruments. If this happens, then any nucleus with a magnetic dipole moment has two possible magnetic states. Either they orient in the same direction as the external magnetic field, or in the opposite direction. The first case is preferrable due to *the minimum energy principle*. However, if we provide them with some extra energy (in NMR it is obtained from an alternating magnetic field that is perpendicular to the external constant field) they will consume the energy and orient against the external constant magnetic field. In this state, the nucleus is said to be in a magnetic *resonance* with the external magnetic field. This difference in energy between two states is detected in NMR spectroscopy and then it is converted to frequences (E = hv for waves). The stronger is an external magnetic field, the more signifiant is the energy gap between the two states, and the easier it is to measure it.\n\n![Two Magnetic States](http://chem.ch.huji.ac.il/nmr/whatisnmr/whatisnmr_files/basisnmr.gif)\n\nAn NMR spectrum looks like this. They are very useful when we need to determine a structure of a chemical compound. However, this effect is only possible with the atoms that possess a magnetic moment. These are all nuclei except for those with an even number of protons and an even number of neutrons.\n\n![An NMR Spectrum](https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/1H_NMR_Ethanol_Coupling_shown.GIF/450px-1H_NMR_Ethanol_Coupling_shown.GIF)\n\nAxes on the spectrum represent the frequency that corresponds to the difference in energy (referred to as *shift*, x-axis) and intensity (y-axis)."},{"metadata":{},"cell_type":"markdown","source":"## Nuclear Shielding\n\nUntil now we have considered a bare proton in a magnetic field. In most molecules this is very unlikely to happen. Molecules are merely a number of atoms that are hold together by some forces. And the atoms are nuclei surrounded by a bunch of electrons. Electrons move around the nucleus, and as you can guess, this movement also results in a new magnetic field. This magnetic field is said to be *induced* by electrons movements and thus is known as *induced magnetic field*. This induced field is oriented in a way to reduce the affection of the external magnetic field. In other words, electrons, moving around a nucleus, weaken the external magnetic field by creating another magnetic field oriented in the opposite direction. This effect is known as ***magnetic shielding***. The effect can be easily expressed in form of equation *B_effective = B_0 - B_induced*.\n\n![Magnetic Shielding in a Molecule](https://ars.els-cdn.com/content/image/3-s2.0-B9780128007808000140-f14-07-9780128007808.jpg)\n\nMagnetic shielding implies that the more electrons are moving around a certain nucleus, the more it is shielded. Therefore, the larger is B_induced, the less is B_effective, and finally the less is the energy of resonance and the corresponding frequency.\n\nTo keep atoms in a molecule together, there must be some forces that are responsible for this. These forces create chemical bonds between atoms. Most of chemical bonds in organic molecules are *covalent bonds*. They are comprised by a pair of electrons shared between two atomic neighbors each. Two electrons = one bond.\n\n![Scheme of Covalent Bonds in a Molecule of Water](http://science4fun.info/wp-content/uploads/2017/02/chemical-bonding-water-h2o.jpg)\n\nA bond between two atoms formed by only electron pair is called a singular bond. Sometimes two atoms share two or even three pairs. This implies that most of the time the electron pairs that form a bond can be found between the atoms that share this pair, and thus the pair is kind of located between two atoms. It is not necessary that they are located right in the middle of bond. Different atoms pull an electron pair with a different force. If pair(s) is/are skewed significantly from the middle, then we talk about a *polarized covalent bond*. This nformation about chemical boundaries is important to keep in mind."},{"metadata":{},"cell_type":"markdown","source":"## Chemical Equivalence\n\nSo far you should realize that the magnetic environment of an atom impacts the resonance energy of the atom and why. Now we are going to see, how we can use it to predict NMR spectra!\n\nIt is pretty obvious that if two atoms of the same chemical element in the same magnetic environment must have equal resonance energy. Here we only consider protons, so let's talk more about influence of environment. The question is how we determine whether two protons are in the same magnetic environment or not, i.e. whether they are ***chemically equivalent*** or not.\n\n![Chemical Bonds in Methane](https://dr282zn36sxxg.cloudfront.net/datastreams/f-d%3A736769339f0e560e89185d12fc442505007b1a7617c870ca2f7a23b4%2BIMAGE_THUMB_POSTCARD_TINY%2BIMAGE_THUMB_POSTCARD_TINY.1)\n\nOn the image you can observe a model of a methane molecule. It has a carbon atom in the middle and four hydrogen atoms around it. The only difference to the real molecule is that hydrogen atoms are oriented in the corners of a right tetrahedron. It can be clearly seen that all four protons are in the same environment and thus are chemically equivalent.\n\nMethane is a very simple molecule. If a molecule is bigger, hydrogen atoms can be of different kinds, meaning they are in different environments.\n\n![Molecules of Methane, Ethane, Propane](https://images.fineartamerica.com/images/artworkimages/mediumlarge/2/methane-ethane-propane-chemical-formulas-and-molecule-models-peter-hermes-furian.jpg)\n\nPropane has a chain of three carbon atoms supplemented with eight hydrogen atoms. Nonetheless, the number of different kinds of protons here is just two, not three. The reason is that a molecule of propane has a plane of symmetry that goes through the carbon atom in the middle. More generally, if a molecule has any element of symmetry and contains hydrogen atoms, it will have less groups of hydrogens than the number of atoms they are attached to. Molecules that have at least one element of symmetry are referred to as *achiral* molecules. You can read more about chiral/achiral compounds in the web, if you want to.\n\nNow, when we can distinguish between different kinds of hydrogen in molecules, we need to say, that the number of these groups is equal to the number of signals in a PMR (Proton Magnetic Resonance - an NMR for protons) spectrum. Scroll up and see the spectrum for ethanol. Different types of hydrogen are highlighted with different colors."},{"metadata":{},"cell_type":"markdown","source":"## Chemical Shift\n\nI hope you recall the meaning of this phrase. I wrote that this is the frequncy of corresponding resonance energy, and I lied. But I lied only partly. Chemical shift *represents* the frequency in a slightly different way than just a raw frequency.\n\nBut why we sophisticate our life with some new fancy terms? It is all because the exact values of frequency depends on the external magnetic field that is generated during experiment, and hence it depends on the used instrument. It wouldn't be very useful if every time we obtained results on a different scale. The simple solutions that works perfectly is use of an etalon for conducted measurements of frequences. As the etalon, TMS (tetramethyl silane) is used most often, as its hydrogen atoms are shielded stronger than in most organic compounds. To compute chemical shift we use a simple formula *shift = registered frequency in Hz * 10^6 / frequency of instrument* and obtain the result in ppm (parts per million). Shifts in such relative unit will stay independent from the characteristics of an instrument used in an experiment."},{"metadata":{},"cell_type":"markdown","source":"## Electrical Effects and Chemical Shift\n\nWe can predict how the molecular structure will affect the chemical shift. There are two main electrical effects in any molecule: the inductive effect and the mesomeric effect. Both are related with the structure of molecule and thus are illustrated in chemical formula."},{"metadata":{},"cell_type":"markdown","source":"### Inductive Effect (*-I*, *+I*)\n\nThis effect is caused by difference in electronegativity of atoms. ***Electronegativity*** is a measure of how strongly an atom of this element withdraws electrons. The greater its value, the stronger is this effect. Inductive effect is denoted by capital *I* and a sign. The sign depends on direction of inductive effect and is defined for each context. Notice, the sign is in fact contextual.\n\nHow then we assign it? You have already seen the simplest organic molecule - methane. In organic chemistry, inductive effect of a C-H bond of methane is 0. Substitution of one of these bonds by another atom or group of atoms leads to a product with general formula *X-CH3*. If substituion causes deshielding of remaining hydrogen atoms, such atom or group of atoms is said to be *electronegative* (in comparison with C-H bond) and demonstrates a *negative* inductive effect denoted *-I*. If introducing a substitute (atom or group of atoms) causes an opposite effect of auxillary shielding of protons, this substitute is said to be *electropositive* (in comparison with C-H bond) and demonstrates a *positive* inductive effect (*+I*). Relative strengths of many substitutes can be found in Google or any other search engine.\n\n![Negative Inductive Effect](https://lh6.googleusercontent.com/xjw4PHiPoMToveKkb8pctyoGlWM4C6359T4Hp7ADVVM14PXN960qCFaji2Vwia3f8l2cmATk9FtOne1h7ZB1NVvcy-dW1pLMQ2mbOxkptVovoMOi1AaA0LCuX6gDqJ-ItBtrk8IN7U-qkWeglA)\n\nWait, why there are multiple deltas on the leftmost carbon? It happens, that inductive effect spreads all over the bonds of the whole molecule. Of course, the power of inductive effect depends on the distance between a substitute and another atom: the more they are apart from each other, the less is the effect."},{"metadata":{},"cell_type":"markdown","source":"### Mesomeric Effect (*-M*, *+M*)\n\nThis effect is more complicated than the previous one. It takes place only if a molecule has a *conjugation system* in its structure. I will not talk here about hybridization of atomic orbitals and method of molecular orbitals. Again, you can find this information somewhere else. It takes some time and many pictures to introduce these concepts. They help explain the mechanism of conjugation.\n\nAnyway, consider a molecule that has some double and maybe triple bonds in its structure. If they are separated by an only singular bond, they form a system of conjugation.\n\nNot only double and triple bonds form conjugation systems. If a lonely pair of electrons is located on an atom, and this atom is separated from a double/triple bond by one singular bond, then there's also a special type of conjugation.\n\nRules for determining the sign of the effect are the same as for the inductive effect. They differ however in ethalon (methan has no double or triple bonds). This time we consider product in general form of *X-CH=CH2*, where *X* is a substitute. If it pushes electrons towards another part of the molecule, it is a *positive* mesomeric effect. If it pulls electrons towards itself, it is a *negative* mesomeric effect."},{"metadata":{},"cell_type":"markdown","source":"## Integration\n\nYou have already seen some NMR spectra. In these spectra the signals are continous peeks. They gives us information not only about the chemical shift (and hence types of hydrogen atoms), but also about their number in the observed molecule! To figure out the numbers of atoms of different types, we need to calculate the area under curve of a single, i.e. integrate the signal. Then, the ratio between areas of different signals reduced to the integer values tells us how many atoms of each group are present in this molecule."},{"metadata":{},"cell_type":"markdown","source":"## Spin-Spin (Scalar) Coupling\n\nWe are coming closer to the thing we need to predict in the competition. It is very common for less or more complicated molecules to have one or few signals that look like multiple signals. Look at this spectrum.\n\n![NMR Spectrum of Chloroethane](https://cnx.org/resources/28eae6eb8c507d72a5fbf0595969085dbaa43442/Fig21.jpg)\n\nFrom the first glance, it seems like the expirienced substance shows 7 discrete signals a-g. However, this spectrum belongs to chloroethane, which has only two types of protons in its structure.\n\n![Two Types of Protons in Chloroethane](https://cnx.org/resources/39e5b8211b0b0b3fe52bd3308ec968bfbf47a901/Fig9.jpg)\n\nWhy this thing happens? Recall, that the area under curve in NMR implies difference in energies between two magnetic states of atoms, where they orient either along the applied magnetic field or vice versa. This energy gap depends on local magnetic environment, i.e. magnetic state of closely located atoms. It follows, that the actual value will be dependent on the *combination* of magnetic moments.\n\nConsider chloroethane. If two hydrogen atoms attached to different carbon atoms are oriented in the same direction as the external magnetic field, they induce their own magnetic field, that weakens resulting vector of induction significantly stronger as if only one of them were the only contributor.\n\n**Chemically equivalent atoms (those with the same magnetic environment) don't couple together!**"},{"metadata":{},"cell_type":"markdown","source":"## The n+1 Rule\n\nYou may have noticed, that the two signals in NMR spectrum of chloroethane differ in number of peaks (4 and 3). The number of peaks can be predicted if we know how many atoms of the foreign proton type are there. This rule has an extremely simple formula: *n + 1*, where *n* is the number of different protons attached to the next carbon atom. Notice that we are only talking about the number of protons that belong to the same type. If we have more complicated case, when there are two different types of protons on both sides, the formula will be slightly modified and turned into a product *(n_1 + 1)(n_2 + 1)*, where *n_1* is the number of protons of the first type, and *n_2* is the number of protons of the second type.\n\nAdditionally you can predict the ratio of intensities for each peak. The ratio is also described by the n + 1 rule! In this case you evaluate n + 1, and find the corresponding row in the Descartes' pyramid. Add colons between numbers in the row - and it's done.\n\n![Descartes' Pyramid](http://3.bp.blogspot.com/-_LtpyQxSj0Y/Tbj0rktmW3I/AAAAAAAAAOY/tqmeOIKopcc/s320/PascalsTriangle.gif)"},{"metadata":{},"cell_type":"markdown","source":"## Coupling Constant\n\nAt last, what we actually try to predict? What is the coupling constant? The coupling constant shows the degree of spin-spin coupling, and is equal to the distance between neighboring peaks in an NMR signal expressed in Hertz. It contains information about relative bond distances and angle between splitting atoms.\n\nCoupling constant arises for the same reason as coupling itself: there are many possible combinations of magnetic states of different types of atoms."}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}