  Context. Magnetic fields are important to the dynamics of many astrophysical
processes and can typically be studied through polarization observations.
Polarimetric interferometry capabilities of modern (sub)millimeter telescope
facilities have made it possible to obtain detailed velocity resolved maps of
molecular line polarization. To properly analyze these for the information they
carry regarding the magnetic field, the development of adaptive
three-dimensional polarized line radiative transfer models is necessary. Aims.
We aim to develop an easy-to-use program to simulate the polarization maps of
molecular and atomic (sub)millimeter lines in magnetized astrophysical regions,
such as protostellar disks, circumstellar envelopes, or molecular clouds.
Methods. By considering the local anisotropy of the radiation field as the only
alignment mechanism, we can model the alignment of molecular or atomic species
inside a regular line radiative transfer simulation by only making use of the
converged output of this simulation. Calculations of the aligned molecular or
atomic states can subsequently be used to ray trace the polarized maps of the
three-dimensional simulation. Results. We present a three-dimensional radiative
transfer code, POlarized Radiative Transfer Adapted to Lines (PORTAL), that can
simulate the emergence of polarization in line emission through a magnetic
field of arbitrary morphology. Our model can be used in stand-alone mode,
assuming LTE excitation, but it is best used when processing the output of
regular three-dimensional (nonpolarized) line radiative transfer modeling
codes. We present the spectral polarization map of test cases of a collapsing
sphere and protoplanetary disk for multiple three-dimensional magnetic field
morphologies.
