  We introduce an effective model for $e_g$ electrons to describe
three-dimensional perovskite (La$_{1-x}$Sr$_{x}$MnO$_3$ and
La$_{1-x}$Ca$_{x}$MnO$_3$) manganites and study the magnetic and orbital order
on $4\times 4\times 4$ cluster using correlated wave functions. The model
includes the kinetic energy, and on-site Coulomb interactions for $e_g$
electrons, antiferromagnetic superexchange interaction between $S=3/2$ core
spins, and the coupling between $e_g$ electrons and Jahn-Teller modes. The
model reproduces the experimentally observed magnetic order: ($i$) $A$-type
antiferromagnetic phase in the undoped insulator LaMnO$_3$, with alternating
$e_g$ orbitals and with small Jahn-Teller distortions, changing to a conducting
phase at 32 GPa pressure, and ($ii$) ferromagnetic order in one-eight doped
La$_{7/8}$Sr$_{1/8}$MnO$_3$ and in quarter doped La$_{3/4}$Sr$_{1/4}$MnO$_3$
compounds. For half-doped La$_{1/2}$Ca$_{1/2}$MnO$_3$ one finds a competition
between a ferromagnetic conductor and the CE insulating phase; the latter is
stabilized by the Jahn-Teller coupling being twice larger than for the
strontium-doped compound. Altogether, there is a subtle balance between all
Hamiltonian parameters and the phase diagram is quite sensitive to the precise
values they take.
