Scottish law separates the estates of testators into 'heritable estates' and 'moveable estates'.
'Heritable estate' refers to land and buildings. The testator can leave this to whoever he likes; his descendants have no 'legal rights' in respect of heritable estate.
The rest of the estate (such as cash and savings) forms the 'moveable estate'. Assuming that the testator does not leave a surviving spouse (who would have 'prior rights'), his children (including, for the purposes of this calculation, the deceased son) have collective 'legal rights' over one third of the moveable estate. (Where a child is named as a beneficiary, he/she must choose between accepting what is offered under the terms of the will or exercising his/her legal rights. He/she can't have both).
So the daughter and the deceased son each have legal rights to one sixth of the moveable estate. Since the deceased son can't claim his part of the moveable estate , his children have legal rights to equal shares in his entitlement. (e.g. if the deceased son had two children, each of them would have legal rights to one twelth of the testator's moveable estate).
So the testator's grandchildren can claim a total of one sixth of the moveable estate by exercising their legal rights. (They simply have to inform the executor that they wish to do so). The daughter will still receive the whole of the heritable estate. She will also receive five sixths of the moveable estate.
If the testator wishes to keep the amount received by the grandchildren as small as possible, he should invest most of his savings by buying land or property. This will increase the value of his heritable estate and decrease the moveable estate.
Chris