The main spar is usually located near where the lift loads are concentrated, though many full scale wings have been built with a single spar farther back, such as in the case of a laminar flow airfoil. There are even cases where there is no spar at all, such as the North American/Ryan Navion, and all loads are carried by the wing skins and ribs. Perhaps something to consider in an all-composite wing. I design the rear spar to 40 percent of the main spar's capacity. The front spar will normally be about 20 percent of the wing chord length behind the leading edge and the rear spar should be at about the 65 percent position. The strength of the rear spar is a matter of balance. If it is too strong the wing may deflect under high loads in a way that produces wash-in. This is very bad because lift loads will increase, further deforming the wing and failure may result. If the rear spar is too weak flutter may be a problem.
The load on a wing also varies along the span, from tip to tip. The highest load is at the wing root. The simplest assumption about load distribution is that lift is evenly distributed along the wing, with each one-inch section producing an equal amount of lift. That is the method this program uses. In reality the inches of span near the tip don't do their part because air spills around the tip from below to the low-pressure area on the top surface. The sections of span inboard from the tip have to do more than their average share. Because the load is shifted in toward the wing root the simple method of calculation errs on the conservative side. The average lever arm is shorter. Tapering a wing in plan form will have the same effect.
The highest stress on the spar is at the wing root. Think of it this way. The tip section must support only the lift it produces. The section next to it must also support its own lift, and in addition it must support the load from the tip section times their distance apart. The inch at the root has to support its own lift plus the load from each other one-inch segment of span multiplied by that segment's distance from the root. Once again, some simplification is possible if it is assumed that loads are constant from root to tip. The total load can then be treated as if it acts through a point midway between the root and the tip, at a distance equal to 1/4 of the span of the airplane. Line 250 in the program uses this simplification. If loads are assumed to charge from one section of span to another then integral calculus must be used to find RS, the total stress at the wing root. Not My Bag.
You may have noticed that loads vary from root to tip in a similar fashion on both sides of the airplane. In solving the spar load problem then it is only necessary to look at one side of the airplane. Although the program asks for full span in line 50, it is changed to half span by line 70. The same thing is done with weight in lines 150 and 210.
Lines 310 through 450 are where all the real work is going on. These lines contain equations that look at the shape of the spar's cross section and figure out how well it can handle the loads you want to put on it. Line 310 calculates the Moment of Inertia of the spar cross section. I don't know why they call it the moment of inertia, because to my mind nothing is moving. What the final number tells you is how well your cross section shape can resist stress. As you concentrate more of your precious spar material toward the top and bottom of the section the number increases. If you increase the depth of the spar the number increases. To a somewhat lesser extent as you widen the spar the number increases. Think of it this way. Moment of inertia can help you get maximum strength from a minimum amount of wood. Since most of the stress is located in the outer part of the spar section, wood near the center is not loaded very heavily. It's not working very hard, but it weighs just as much as the outer wood fibers that are working their little hearts out, partly to support the weight of those lazy inside fibers.
Line 390 determines the maximum stress in PSI in one spar cap. Stress will be equal in the two spar caps although one will be in compression and the other will be in tension. Line 450 compares the stress from line 390 with 9000 and converts the relative values into a percentage.
Everything after line 450 is just computer gunk to put the results on either your screen or your printer.