Search This Blog

Thursday, December 22, 2011

Chapter Four: Quantum Cats

The last chapter, on relativity, was a warm up to the problem of thinking about weird things.  Remember, things only get weird when they fall outside, usually well outside, our common range of experiences.  We all have this biologically built-in understanding of the world, of physics more precisely, which we’ve acquired from our genetic ancestry and life’s experiences.  We rarely give it much thought, unless magicians play havoc with it to fool us, or physics teachers demand we absorb all the symbolic definitions and formalities and math we need if were going to – say, if we’re going to figure out how to send men and instruments to worlds millions of miles away.  Fortunately, few of us are called on for such flights of fancy.

Special relativity is weird because it involves travelling at speeds no one has ever come close to.  General relativity is weird because it tries to understand the universe as a whole, or at least things much more massive than ourselves; ambitions few of us have ever gotten the itch for.

It’s time now for a different direction.  From now on, we will be focussing on the realm of the vastly small and, often, extremely short-lived.  To give you an idea of just how small, how many molecules of water are in a glassful?  If the volume is about a cup, or, more usefully, let’s use the metric system and call it 100 milliliters or 0.1 liter, then that number is about 33,000,000,000,000,000,000,000,000 or 3.3×1024 molecules.  To capture a feel for just how large a number than is (i.e., how small water molecules are), all of the waters of this planet Earth would take somewhere between 1019 and 1020 glasses to hold it.  That number is at least ten thousand times smaller than the number of water molecules in an ordinary drinking glass.

My opening salvo is, objects that small definitely fall deep into our notions of weird.  You really can’t imagine it all, you can only do calculations with the numbers.  I’m tempted to try to give you a feeling for it; say, by going down to the beach and building a sand castle, and all that.  But sand grains themselves are so large that they fall into the range of common-sense physics, and are barely one iota along our quest for the ultra-small.  If sand grains behaved as atoms and molecules do, this would be a very, very different world indeed.

*          *          *

If you were to go down to the beach anyway, and try to follow the whims and whereabouts and whichways of a sand grain buffeted about by the sea breezes, you would probably feel like a cat chasing the spot of a laser pointer about the house (they go nuts chasing it).  Nevertheless, come, let me take you – a child version of you works best because of its innocence – down to the sea shore to chase a grain of sand.  You will no doubt quickly report to me that it is impossible, you will never be able to do it.  In response, I say,  “I know what you say sounds right, but it can’t be.  Think about it.  At every moment in time the sand grain has:  a) an exact mass; b) an exact speed; c) an exact direction it’s travelling; d) an exact momentum; e) an exact kinetic energy; f) an exact temperature; g) an exact albedo (how much of the sun’s light it reflects); and – I’m sure I could come up with other measurements, but you get the idea.  You just need to apply yourself more diligently to follow these quantities.”

A true child would not comprehend this quandary, but just find something else to play with.  But the adult you gets the point:  while in practice we simply cannot move quickly enough to follow a sand grain’s various dances, in theory it could be done.  Could be.  Are you certain?  What if I were to start shrinking that grain, ever smaller and smaller, until it was so small it fell beyond the range of the most powerful light microscopes to see it, down to something of the size of a water molecule?  What would happen then?

We suddenly feel as though we’re in the middle of Paul McCartney’s song “Lucy in the Sky With Diamonds” or perhaps “Penny Lane”; a surreal, dreamlike state where all the ordinary rules of reality have been suspended, and we have to figure out the new ones.

And in truth, that’s not just metaphor.  How reality looks and acts like at this scale is truly, and astonishingly, very, very little like sand grains and castles and rail cars.  And it is, at least at first, just a little unsettling.  For it means, for example, we have to throw away things like our previous, common-sense idea of exact measurements.  Oh, you can still make them, but at a price.  That price is complete loss of all information about something else equally measurable.

As a concrete example of this (always turns abstract concepts into concrete visions, when possible, remember), try to measure the position where our sand grain scaled down to water molecule can be found at any given moment.  Yes, you can still set up a measuring system that gives you a 100% accurate value for that position.  But only for that moment when you make the measurement.  And where has the grain gotten too after that?  Strangely, oddly, bizarrely, utterly incomprehensibly we have no idea!  In order to measure its position exactly, we have completely scrambled all information about its speed and direction from that position.  It, literally, and I mean literally in the literal sense here as in quite absolutely literally, could now be anywhere in the known universe!

You see, we must hand over our magnifying glasses and microscopes, and radar guns, and all other mechanisms for measuring the quantities of things, over to the police of this Brave (perhaps with a few shots of gin) New World, and accept new tools for spying on the world about us.  These tools only allow us to make probabilistic approximations on things.  By accepting limits on how well we can measure, we can measure other things too, albeit within their limits as well.

If I sound heavy-handed in repeating again that we are not dealing with metaphor or analogy, but with nature as it actually is, please be patient.  We are so accustomed to our “normal” rules of reality that different ones do sound like artistic inventions or flights of the imagination.  I merely want to emphasize over and over that what we are faced with is as real as the computer I’m typing these words on.  But it is only in the land of the ultra-miniature do our new rules come into play, that is, in a way that we cannot fail to notice even if we try.

*          *          *

I just used the word probabilistic, I suspect not for the first time.  In talking about probability we all, I think, have a good grasp of what this concept means.  We don’t know – sports analogies always work best – who is going to win the World Series next year but we can analyze the different teams and the caliber of their players and compute, even if roughly, probabilities – likelihoods, odds, where to place our money, and so on.  In a similar fashion we cannot predict the height of a human being chosen at random, but we can use probability to come up with a good ballpark (pardon the pun) figure.  In fact, the particular method of probability used here is simply called the Gaussian Distribution function, illlustrated below:

Figure V.


Don’t concern yourself with the symbols, like μ (mu) and σ (sigma), although we will return to them later.  Note simply that the distribution is highest in the middle of the curve, and drops off on either side, coming close to but never reaching zero.

A measurement of a large number of human heights, plotted on a graph, would look much like this.  There would be a high central region where most of the heights found themselves, and then declining tails of progressively shorter and taller – and fewer – people.  A person chosen at random has a 68.2% chance of falling within one standard deviation, or 1σ, of the highest, most central height, called μ or the norm or average; a 95.4% of coming within 2σ of the norm; and so forth.

And that’s it.  All we can say.  We simply cannot speak with certainty the height of an individual chosen randomly.  There is a big difference, however, between this problem, which is part of ordinary reality, and the “same” problem in the quantum world.  In the world we’re used to we can still measure the selected individual and reveal himself to be an individual (e.g., David Strumfels) with a height of six feet two inches.  But in the quantum world, no.  First, there are no individuals; and if we try to make measurements which with to create individuals, then other important information about them is irretrievably lost.  In the quantum world, probability rules with an iron fist.

We can place this in more prosaic contexts however.  According to the laws of the quantum world, we cannot say exactly where a water molecule is in a glass; but we can calculate a probability distribution, similar to the Gaussian but not eactly the same.  There  is, in fact, a famous calculation chemistry and physics students perform that is quite similar:  a lone electron in a (one-dimensional) box.  You cannot say precisely where the electron is, you can only construct an equation showing the probabilities of being in the box somewhere at any given moment.

Given that I’ve raised the subject of electrons …

*          *          *

Atoms.  We’ve all heard about them.  Unless you truly slept through all your schooling you heard that:  a) everything is made from them (not true); b) they’re so tiny nobody can even see them (also not true); and c) they’re composed of a tiny, dense nucleus made from protons and neutrons, with even tinier electrons spinning around it (partially true, but critically untrue for where this discussion is headed).

It is time to continue on our journey.  We were at the level of water molecules, and as as we work our way down past that, past individual atoms even, down finally to electrons, things change little.  Mainly, those probability curves just keep getting bigger.  They get so big, in fact, that by the time we’ve reached the level of electrons the curves are complete masters of their behaviors.

Our interest in electrons is simple enough; they are what make chemistry possible, and control most of what it can do.  Not everything – remember the discussion on organic chemistry and geometry before – but without electrons there is no such thing as chemistry at all.

Some further evidence of just how strange the quantum world is worth the effort here.  In the quantum world probability is truly just that; by that I mean that if, say, we knew all the forces and effects working on a coin toss we could predict, with absolute certainty, whether a given toss would be heads or tails.  And it is always one or the other, nothing … well, nothing in-between, curious as that may sound.  In quantum probabilities, no such luck however.  All we can do is make observations, in which we will see this or that or something else, an infinity of possibilities with each one having its given probability.

This might sound purely academic, but study the picture below:

Figure VI.

The gist of this, Erwin Schrödinger’s famous quantum cat experiment, is a sealable container (usually a box), within which resides:  a) a live cat; b) a vial of deadly poison; c) a hammer and a lever which can drop the hammer, breaking the vial and killing the cat; and d) a single radioactive atom with a 50% probability of decaying within an hour and which, if it does decay will trip the lever, again killing the cat.  Unlike the picture however, the box is not open but completely sealed so that no information on the cat’s state (alive or dead) can get out.

You see, the quantum world is even stranger than I’ve described.  I’ve spoken of making observations and getting results according to probabilities, as though the results were already there waiting for us to unveil them.  It’s worse than that.  The results don’t even exist until we make the observation!  Quantum physicists speak of things like “collapsing the state function” among other arcane words and phrases, but what they mean is making an observation.  The act of observation reduces the infinitely many probabilities into a single, actual result, and that result doesn’t exist until the observation is made.

Sounds like magic, I know, or some kind of tomfoolery.  But it is the simple truth.  A truth that has been demonstrated with absolute certainty by thousands of experiments, making measurements to many naughts beyond the decimal point.

*          *          *

Let’s return to our concrete example, the quantum cat.  Seal the box, wait an hour – remember, I said that there is a 50% probability of the atom within decaying within that time span – then open it again.  What will you see?

This part of the answer is simple.  Either the atom has decayed, the lever tripped, the vial containing the point released, and the cat dead; or the atom didn’t decay and the cat is very much alive.

The hard part of the answer is, what’s the state of the cat just before opening the box?  Your first reply I’ll bet is the same as before, though you’re probably suspicious by this point.  You smell a rat following the cat and you think I’m trying to pull a fast one on you.

If you feel that way, that’s actually good; it means you’re following the discussion.  (See, I told you you could do it!)  Remember I just said that, at the quantum level, the result of an observation doesn’t exist until it is made.  The cat isn’t dead or alive prior to opening the box – unless of course, you decide that the cat is an observer who saw the vial being smashed or not, which, to be honest, is a valid argument here.  So:  what does exist?

Recall that I said that the result of the coin toss experiment is never somethin “in-between?”  I meant that it’s in a head state or tail state even before we lift our covering hand and make the observation.  Again, no such luck with the quantum cat.  The convenient way of treating it, that is what scientists do, is to say that it is in a “superposition” of both states.  It’s both alive and dead; until you open the box that is, and collapse the state fuction into one of the other component states.

I advise not over-thinking about this.  Scientists and philosophers and other pundits to this day argue about what quantum physics implies about reality and our relation to it.  Even the cat experiment is taken seriously by some, while a joke by others.  My personal take about the experiment, by the way, is that it is not physically possible; you can’t construct a container which allows no information to leak out about the cat being dead or alive, meaning that it is always possible to make a measurement about the cat’s state without opening the box; whether or not the measurement is actually made or not (what exactly is a measurement or who or what makes it, anyway?) is irrelevant.  But their are problems with this stance too.  So please – don’t lose any sleep over it.

The pragmatic truth about quantum physics is that scientists use it because it works.  And there are very real versions of the cat experiment that can and have been done, experiments which have shown that the superposition of states with the result not existing until observation is made is correct.  As for the philosophical implications, most scientists are too practical-minded to worry about them.  Too much.

*          *          *

It is now time to return to electrons, and how they behave in atoms and molecules.  Remember, this is the fundamental requirement just to have chemistry, so we need a reasonable feel for this before we can continue.  Fortunately, a reasonable feel is all we need.  To get that, all is needed is to take what we learned about cats in the quantum world and apply them to this new arena.

Like cats in a box, electrons in atoms and molecules exist in quantum states; these states describe such (indirectly) observable quantities as their energies, magnetism, where they’re likely to be found, and so on. Also, like the cat’s fate, the states are quite distinct from each other, and the electron can only move from one to the other, never being found in-between.

If you have been wondering why the world of the infinitesimally small is called quantum, the answer lies here.  In the quantum world things generally exist in discrete states and not somewhere along a continuum.  To give another example, imagine getting in your car, pulling out along along a highway, and accelerating to 50 mph.  It seems to you that the acceleration is continuous, with no breaks anywhere; there are no discrete sepeed states, and you don’t make jumps from one state to another.  But if quantum rules applied strongly at “ordinary” levels of reality, you might find that you could only do the speeds 0, 10, 20, 30, 40, 50 mph exactly, jumping from 0 – 10 – 20 instantly.  You could not do 36.568 mph, for that “state” doesn’t exist.  Of course, it’s possible that the actual states don’t comprise a continuum anyway, they are just too close together to measure.  In fact, this is the actual case, and quantum physics applies at the medium, large, and enormous scales of reality too.  It’s just that as the masses involve increases, the states grow ever and ever close together.  Even at the level of sand grains they are far too close together to be observed.

So:  electrons in atoms and molecules do not orbit around nuclei, like planets around the sun, but exist in appropriate (usually lowest energy) quantum states.  All the images of atoms being like miniature solar systems are innacurate in this respect.  So why do we use them?  Simply, the actual picture of an atom is too difficult to illustrate at our reality level, and the solar system works best here.  It is accurate in a number of ways that justify its use.  Just bear in mind that, when it comes to electron behavior, and it’s relationship to chemistry, it really doesn’t work at all that way.

Before I go on, let me remind you about thermodynamics and entropy again.  This is a very complex subject, but all we need to know is that electrons, like everything else, “perfer” to be in their lowest energy states.  In a multi-atom molecular, electrons are attracted to more atomic nuclei (made of protons, and particles of opposite charge attract one another), and this alone would be large molecules the most stable states of matter.  Careful.  The larger an atom/molecule the more electrons there are too, and these tend to repel each other, thereby raising the energy.  Exactly what types and number atoms and molecules which from atoms is largely a balancing act between these two forces.

The simplest, and most abundant atom in the universe is hydrogen, consisting of a one proton nucleus and one electron distributed about it.  This is not the most stable atom; it’s abundance is purely the result of how the universe has evolved.  Next to hydrogen, helium, with a two-proton nuclear and two electrons about it, is most common; it is more stable that hydrogen, but is still far from maximum stability and again it’s abundance is explain by cosmic evolution.

As for molecules, hydrogen usually exists in diatomic molcules, in this case H2.  This is because the two electrons are more strongly drawn toward the two nuclei than they repel each other.  Helium exists as monoatomic He atoms, however, because the four electrons exert a more profound effect than the two, albeit di-proton nuclei, can counter.

As we climb the periodic table of elements (just a diagrammic listing of all elements, to be read left to right and top to bottom) you see hydrogen and helium in the top row:

Figure VII.

The elements Li through Uuo don’t follow an easily made out trend when it comes to stability and molecule making, but there are general trends that can be worked out and understood, usually with a lot of hairy math and computer time.

As this section is in fact about molecules and not lone atoms, what we want is a feeling for how the constituent atoms form them, with the particular shapes they have.  A good place to start is to return to good old water, a simple molecule that can illustrate many of the principles.

Water is made from two hydrogen and one oxygen atoms:  the famous H2O.  But why that particular formula, and why do water molecules take on a bent shape:

Figure VIII.

No need to go into the details here.  Basically, the available basic shapes of the oxygen atom make up a tetrahedron (remember, I said you need to recall some basic geometry):

Figure  IX.

      The ogygen nucleus sits at the center of the tetrahedron, and the electrons are “at” (actually around) the vertices (the connecting lines are the chemical bonds).  If you imagine sticking the hydrogen atoms (whose electrons make up spherical states) at two of the vertices, the water water molecule shape should pop out at you.  Each electron on the hydrogen atoms pair up with a “lone” electron on ogygens atoms pair up; this is another quantum oddity in which a state can hold only up to two electrons; any more and they spill over into other states, usually larger, more energetic ones.  This limitation, by the way, is why atoms and molecules can build up.

A more complex example of a molecule is glucose (blood sugar):

Figure X.


Here, the black spheres are carbon atoms, the red oxygen, and the white hydrogen.  Ignore the HC=O part at the upper right end (the = is called a double bond) and for the moment, concetrate your attention on the carbon atoms.  Notice how the bonds sticking out of them make for tetrahedrons too?  Carbon can bond with as many as four other atoms so it is very clear here.  But the H-O-C parts are also, like water, bent, indicating the same tetrahedral shape as in water.  But oxygen can bond with only a maximum of two other atoms, so the other points of the tetrahedra are empty.

I am not implying that all bonds have tetrahedral shapes.  Far from it.  It is merely one of a myriad shapes which is fairly common, especially among atoms in the top two rows of the periodic table.  The HC=O group, for example, is flat and triangular.  Another shape is represented below

Figure XI.

This molecule (which has a negative three charge) is comrpised of two shapes.  The 6 CºN portions are linear (the º is called a triple bond), while the central FeC6 part is an octahedron, the carbon at the center:

Figure XII.

As said, there are numerous other shapes as well.  And shapes can be bonded to shapes, creating large, complex molecules, such as proteins and DNA and many other molecules found in our bodies.  Still, other molecules possess even simpler shapes, such as O=O (O2), H-H (H2), NºN (N2), O=C=O (CO2), and so on.  The possibilities are, for a practical purposes, infinite, and many millions of molecules are now known about.

Many of these molecules are called “organic” and it is time to know why.


Saturday, December 17, 2011

Chemistry at Venus' Cloud Tops

There is a curiosity I keep wondering about concerning the inner solar system’s planet’s atmospheres.  I have often read how Earth’s powerful magnetic field helps to deflect the solar wind and maintain our dense atmosphere.  Mercury, the moon, and Mars have only weak magnetic fields and it is asserted that their little to no atmospheres are the result of the wind ionizing the gasses and then literally stripping them away.

But there was always one obvious exception to this generality:  Venus.  Venus too has no magnetic field but easily possesses the densest atmosphere of the inner worlds, much denser than Earth’s.  Part of this is probably due to the carbon dioxide composition of Venus’ atmosphere; CO2 is a large, heavy molecule that is no doubt easier to retain than Earth-like gasses of oxygen, nitrogen, argon, and water vapor.  Furthermore, the active (though periodic) heavy volcanism on Venus means that this gas is being regularly generated and introduced into the planet’s atmosphere (the early loss of heavy volcanism is probably why the same hasn’t occurred on Mars), perhaps as fast or even faster than the solar wind can strip it away.

But I wonder if there is another reason. Venus is topped by a thick layer of sulfuric acid clouds, which largely (I think) overlays the carbon dioxide nearer the surface.  This layer could act as a shield against incoming electrons and protons from the sun.  Sulfuric acid is a very heavy molecule which would probably fracture into smaller radicals and ions when struck by such particles.  Possible reactions could be:

 H2SO4 + e- ® OH- + HSO3·
 H2SO4 + p+ ® H2O2 + SO22+

If OH- ions are formed they are probably to weak to be helped by Venus’ gravity, but they might recombine with other radicals/ions first.  The other species will probably also hang around long enough to recreate sulfuric acid, while scattering the electrons and protons at lower energies.  Bear in mind, this is probably a very small sampling of the kind of chemistry that occurs at Venus’ cloud levels.  If it is happening then Venus protects its atmosphere with chemistry instead of magnetism.  Similar chemistry could be going on at Saturn’s moon Titan’s cloud tops, although the solar wind is much weaker there.

A Favorite Way of Picturing Deep Time

Portraying geology and geology in terms of "deep time" (essentially goin back to the beginning of Earth and the solar system) isn't easy, but I think this picture does a reasonably good job of it.

Spice, Salt, and Civilizations?

Some years ago a writer I much admire named Jared Diamond wrote Guns, Germs, and Steel, the main premise of which (though it isn't in the title, oddly) is that Eurasian civilizations took off sooner and faster than African or American due to the large number of domesticatable plants and animals living there (e.g., cattle, swine, chickens, wheat and other grains, etc.), which is why Eurasia came to dominate the rest of the world so badly once we developed ocean going vessels.

If we define civilization as the transition from nomadic to settled cultures, there may be another factor, this one concerning food.  The reason uncivilized cultures are nomadic is that food is a constant requirement but, with obvious exceptions like tropical areas, is not plentiful anywhere all year round.  Their is a time of plenty, and a time of -- well, what?  Without means to preserve (many) foods, it's either go hungry or move to new places of plenty.  Hense nomadism.

We take freezing and refrigeration (in technologically modern cultures) as the obvious way to preserve meat, fish, and other perishable food items, but that's only been quite recent (and still is no where near universal).  Prior to cold, the main preservatives used by humans were salt and spices -- even if you went to market everyday such places often had to be kept going by sellers and producers using salt & spices to keep their foods reasonably fresh for their buyers.

I don't know what the archeological evidence here is (which means I'll have to check it), but may I suggest that at least part of what triggered settled behaviors in Homo sapiens was the discovery of substances which can preserve perishable foods for fairly long periods?  At least this makes sense to me.  Nomadism is a brutal way of life, happily abandoned the moment people can do so.  On the go most of the time, carrying all you own with you, over mountain passes and deserts and other nasty places?  In truth, it doesn't even sound romantic.

When you first settle, you're still uncivilized in all other ways.  A stone-age culture that doesn't move about.  Although there are other obvious reasons, perhaps one of the causes of tropical people living "primitive" lives long after the rest of us have abandoned them, is the year-round presence of food.  They're settled because they don't have to move.  And even though many of them do use preservation methods, they're not an absolute essential; you literally can get fresh food every day.

Well.  I suppose I'm not the first person to think of this.  But I haven't seen a book entitled Spice, Salt, and Civilizations, anywhere, by anyone.  So proably not too much has been done with this idea amongst the lay public, and maybe not even among scientists.  If so, I'd love to hear about it.

Friday, December 16, 2011

The implications of this picture are either highly disturbing or highly exciting, or both. But they can't be neither.

Some Belated Tricks with Java and Excel VBA


Several years ago, when I was working for Dr. Jean-Claude Bradley at Drexel University, I posted on a number of programming projects on the UsefulChem blog site (http://usefulchem.blogspot.com/).  I recall a flurry of interest in how I got Excel VBA programs to call Java programs and how Java could make Excel spreadsheets.  It’s probably a lot easier now, but here were my tricks below.  First part is how to get VBA to run any software and wait for its completion:
________________________________________
‘Declarations
Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThread As Long
End Type
Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Long
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type
Private Declare Function CreateProcess Lib "Kernel32" Alias "CreateProcessA" _
                                 (ByVal lpApplicationName As String, ByVal lpCommandLine As String, _
                                  ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
                                  ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
                                  lpEnvironment As Any, ByVal lpCurrentDirectory As String, _
                                  lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "Kernel32" _
                                  (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
 ‘The actual function.
Private Function RunWaitApp(lpCommandLine As String, wShowWindow As Integer, bWait As Boolean, _
                            Optional lWaitTime As Long) As Boolean
  Dim sinfo As STARTUPINFO
  Dim pinfo As PROCESS_INFORMATION
  Dim res As Long
  Dim lWait As Long
 
  If bWait Then
    lWait = lWaitTime
  Else
    Shell lpCommandLine, wShowWindow
    RunWaitApp = True
    Exit Function
  End If
 
  sinfo.cb = Len(sinfo)
  sinfo.wShowWindow = wShowWindow
  res = CreateProcess(vbNullString, lpCommandLine, 0, 0, True, &H20, ByVal 0&, vbNullString, sinfo, pinfo)
                 
  If res <> 0 Then
    Do
      res = WaitForSingleObject(pinfo.hProcess, lWait)
    
      If res <> &H102& Then
        Exit Do
      End If
 
      DoEvents
    Loop While True
   
    CloseHandle pinfo.hProcess
    RunWaitApp = True
  Else
    RunWaitApp = False
  End If
End Function
_______________________________________

A bit windy, I know, but you need write the module only once, then copy, paste, and call it wherever needed.

The code to create Excel spreadsheets from within Java then required a special library import, of which I could only find one at the time but am sure now there are many others.  The full code is:
________________________________________

import java.io.*;
import java.util.*;
import org.apache.poi.hssf.usermodel.*; // The special import
 
public class CreateXLS
{
  public static void main(String[] args)
  {

    if (args.length < 1)
    {
      System.out.println("Usage:  java CreateXLS ");
      System.exit(0);
    }

    try
    {
      String saveDirectory = args[0];
      String feedFile = args[1];
      System.out.print("Creating XLS files for items from " + feedFile + " ... ");
      File dd = new File(saveDirectory);
      if (!dd.isDirectory()) dd.mkdir();
      String separator = System.getProperty("file.separator");
      String newLine = System.getProperty("line.separator");
      String tab = "\t";
      FileWriter fw;
      FileOutputStream os;
      HSSFWorkbook wb;
      HSSFSheet sheet;
      HSSFRow row;
      Feed feed = Feed.loadFeed(feedFile);
      ArrayList itemList = feed.getItemList();
      Item item;
      Molecule molecule;
      Field suppliers;
      ArrayList suppliersList;

      for (int i = 0;i < itemList.size();i++)
      {
        item = (Item) itemList.get(i);
        molecule = item.getMolecule();
        fw = new FileWriter(saveDirectory + separator + item.toString() + ".txt");
        os = new FileOutputStream(saveDirectory + separator + item.toString() + ".xls");
        wb = new HSSFWorkbook();
        sheet = wb.createSheet();
        row = sheet.createRow((short) 0);
        row.createCell((short) 0).setCellValue("UC Number:");
        row.createCell((short) 1).setCellValue(item.toString());
        fw.write("UC Number:" + tab + item + newLine);
        row = sheet.createRow((short) 1);
        row.createCell((short) 0).setCellValue("SMILES");
        row.createCell((short) 1).setCellValue(molecule.getSMILES().getFieldContents());
        fw.write("SMILES:" + tab + molecule.getSMILES().getFieldContents() + newLine);
        row = sheet.createRow((short) 2);
        row.createCell((short) 0).setCellValue("InChI:");
        row.createCell((short) 1).setCellValue(molecule.getInChI().getFieldContents());
        fw.write("InChI:" + tab + molecule.getInChI().getFieldContents() + newLine);
        row = sheet.createRow((short) 3);
        row.createCell((short) 0).setCellValue("Image URL:");
        row.createCell((short) 1).setCellValue(molecule.getImageURL().getFieldContents());
        fw.write("Image URL:" + tab + molecule.getImageURL().getFieldContents() + newLine);
        row = sheet.createRow((short) 4);
        row.createCell((short) 0).setCellValue("Substructure Search:");
        row.createCell((short) 1).setCellValue(molecule.getSubStructureSearch().getFieldContents());
        fw.write("Substructure Search:" + tab + molecule.getSubStructureSearch().getFieldContents() + newLine);
        row = sheet.createRow((short) 5);
        row.createCell((short) 0).setCellValue("Item Page:");
        row.createCell((short) 1).setCellValue(molecule.getItemPage().getFieldContents());
        fw.write("Item Page:" + tab + molecule.getItemPage().getFieldContents() + newLine);
        row = sheet.createRow((short) 6);
        row.createCell((short) 0).setCellValue("Canonical MW:");
        row.createCell((short) 1).setCellValue(molecule.getCanonicalMW().getFieldContents());
        fw.write("Canonical MW:" + tab + molecule.getCanonicalMW().getFieldContents() + newLine);
        row = sheet.createRow((short) 7);
        row.createCell((short) 0).setCellValue("Natural MW:");
        row.createCell((short) 1).setCellValue(molecule.getNaturalMW().getFieldContents());
        fw.write("Natural MW:" + tab + molecule.getNaturalMW().getFieldContents() + newLine);
        row = sheet.createRow((short) 8);
        row.createCell((short) 0).setCellValue("Suppliers:");
        fw.write("Suppliers:");

        suppliers = molecule.getSuppliers();
        suppliersList = suppliers.getFieldContentsList();

        if (suppliersList != null)
        {

          for (int j = 0;j < suppliersList.size();j++)
          {
            row.createCell((short) 1).setCellValue((String) suppliersList.get(j));
            row = sheet.createRow((short) (j + 9));
            fw.write(tab + (String) suppliersList.get(j) + newLine);
            row.createCell((short) 0).setCellValue("");
          }

        }

        wb.write(os);
        os.close();
        fw.flush();
        fw.close();
      }

      System.out.println("[ok]");
    }
    catch (Exception e)
    {
      System.out.println("[failed]:  " + e.getMessage());
    }

  }

}

________________________________________

This is all five years after the fact, and much has changed since then, but hopefully someone will find it useful.

Delayed-choice quantum eraser

From Wikipedia, the free encyclopedia https://en.wikipedia.org/wiki/Delayed-choice_quantum_eraser A delayed-cho...