As of now, more than 3600 planets have been detected outside of our own Solar System. By contrast, a comprehensive picture of how they were born remains lacking. The reason is that the process of planet formation involves complicated interactions between solid materials, gaseous medium, and magnetic fields. We propose two sub-projects to attack two of the most difficult stages in the course of planet formation around young stars. First, we plan to use the Pencil Code to simulate a continuous size distribution of dust particles in a gaseous protoplanetary disk and investigate how they can concentrate themselves into high density and drive the formation of km-scale planetary objects, known as planetesimals, that are necessary precursors of the would-be planets. The simulations will also help us understand how dust particles of various sizes are transported and redistributed in protoplanetary disks via the particle-gas streaming turbulence. Second, we plan to use the FARGOCA code to resolve gas accretion onto a planetary core of a few tens of Earth masses in 3D and study the physical conditions for a gas giant like Jupiter to form. Finally, another part of this project will be a continuation of our earlier SNIC medium allocations that has supported a wide range of topics in theoretical astrophysics research at Lund Observatory, including exoplanets, black holes in active galactic nuclei, compact binaries, and gamma-ray bursts.