I'm a math person, sort of.
So let's start with the "given" points (many of which I disagree with.)
1) It's possible to create a permanent
Mage's Magnificent Mansion (it's not on the list of spells that can be made
Permanent.)
2) It's possible to affix the opening to an item, like a flying carpet (nothing to support this in the spell description.)
3) Caster level is 13 (the minimum needed to cast the spell in the first place.)
If we accept those points as "Given", we get...
At 13th level, the Mansion will have 39,000 cubic feet of space. (3 10 foot cubes per caster level.)
The unanswered (and unasked) question in this is, how tight are you willing to pack those soldiers?
If we decide that the rooms will have 10 foot ceilings, and we're going to pack the soldiers one per 5 foot square, we get 4 men per 10 foot cube, times 39 10 foot cubes, and we get 156 men in your
Mansion spell. That's 250 cubic feet per person, for 12 people per caster level, in case you were keeping track.
If we're willing to drop the ceiling height to 8 feet we get 48.75 10x10 squares, and our invasion force goes up to 195. That's 200 cubic feet per person, or 15 people per caster level.
6 foot ceilings? We can get 260 men in there. That's 150 cubic feet per person, or 20 people per caster level.
The spell says that the air is always fresh and clean, so it might be claustrophobic, but it will work.
If they're in there for a relatively short time, and can stand to be packed in like cattle you can quadruple those numbers. Really claustrophobic, and God help us if someone farts.
Now, more realistically, allowing for walkways, a place to sit or lay down and space for gear, you're talking 50 people. That's allowing a cot and footlocker, plus space between. Double-deck the bunks and you can almost double the number (foot lockers don't double-deck too well).
I wouldn't try to keep even that reduced number in there for any period of time.