For extract, the amount of sugars which are available to the process is known and constant (for a given weight of extract), so the program calculates the amount of sugars available in the system based upon [weight of extract] x [extract potential]. Post boil, you have a set volume going to the fermenter. The amount of sugar remains constant. So the gravity can be calculated by [amount of sugars in system] / [post boil volume]

Any losses in the process, such as trub loss, results in a loss of these sugars. Since there is only a finite amount of sugar, the gravity at the end drops as a result of the post boil dilution of the finite amount of sugar in the system.

So as an example, if you have 3 kg of extract with a potential of 1.044 [44 ppppg = 367 ppkgpL] the resultant amount of sugar in the system is 367 x 3 giving us 1101 sugar points in the system. With a 22 liter batch, this ends up at 1101 sugar points / 22 liters = 50 sugar points, which will give a gravity of 1.050

Now, if you have 2 liters of trub in your process, your end of boil volume is actually 24 liters [22 liters batch size + 2 liters of trub], so you will end up with 46 sugar points or a gravity of 1.046.

That covers the extract setting in BeerSmith. So what changes when we go to all-grain?

In the all-grain setting, the program must now have some figure to estimate how much sugar from the grains is actually getting into the system. In BeerSmith, this is defined by the Brew House Efficiency (BHE) which is also denoted as total efficiency. This efficiency is defined by the amount of sugar from the grains which actually makes it into the fermenter. It applies this to the volume in the fermenter to determine how much sugar is needed from the grains in the recipe. The program then adds in the sugar in the other process losses (trub loss, mash tun losses) to determine how much sugar is actually extracted from the grains. This value of sugar divided by the total potential sugar in the grain bill gives you the mash efficiency.

Note that in doing this if your BHE and process losses are set too high, the program will calculate a mash efficiency greater than 100%.

Getting back to our example, if we replace the extract with 4.5 kg of base grain with a potential of 1.038 [38 ppppg = 317 ppkgpL] and set out BHE at 75%. If we assume no mash or trub losses, the ending gravity becomes: 4.5 kg * 317 ppkgpL * 75% / 22L = 49 gravity points or a gravity reading of 1.049. Our mash efficiency ends up at 75%, since there are no losses in the system.

With a trub loss of 2 liters added to this example, the potential at the end remains the same at 1.049, since the calculation above remains true. The actual amount of sugars which enters the system, however, is increased by 2 L * 49 gravity points = 98 sugar points. The total extracted from the mashing of the grains now becomes 4.5 kg * 317 ppkgpL * 75% + 98 sugar points = 1070 sugar points in fermenter + 98 sugar points in trub = 1168 sugar points. The maximum possible sugar which you can get from the grain bill is 4.5 kg * 317 ppkgpL = 1426 sugar points. This makes the mash efficiency in this example: 1168 / 1426 = 82%.

When in all-grain mode, the program assumes the extract is just like grains, so it applies the BHE to the equations and when you put in a trub loss it will just demand more sugars from the extract to satisfy the calculation of BHE * batch volume * total sugars available equation.

I know I went into more detail than you expressed, but thought it might be helpful in understanding just how the program works.