Strong magnetic fields make neutron stars potential sources of detectable electromagnetic and gravitational-wave signals.
Hence, inferring these magnetic fields is critical to understand the emissions of neutron stars.
However, the interior magnetic field configuration remains ambiguous due to the lack of direct observational evidence.
Here, for the first time, we show that the internal magnetic field strength along with the composition of a neutron star can be directly constrained by detecting the gravitational waves from the phase-transition-induced collapse of a magnetized neutron star.
In particular, we study the effects of magnetic fields and phase-transition-induced collapses on the dynamics, oscillation modes, and gravitational-wave signatures of compact stars through dynamical simulations.
Hence, this work has demonstrated that much information inside neutron stars could be extracted by measuring the oscillation modes from the gravitational waves emitted by the stars.