I have to build a bilayer using a structure obtained in a previous MD simulation. In the structure, some chains of the molecules cross the simulation box as shown below. I added water layers to the structure as below. Since some of the structure parts are oriented out of the box, I would like to know whether doing the MD simulation for the prepared structure (below image) is correct or do I have to arrange the molecules in a manner that molecules are not going out of the box.
Usually one needs to employ periodic boundary conditions (at least in the horizontal directions). Any atoms which fly outside of the box will be mapped to the opposite side. This also has to be properly considered for the forces between the atoms, as the atoms close to your border will interact with those from the very opposite side of the simulation box.
It is best to start with one or two atoms in vaccuum to check these BC. Will the forces between them work accross boundaries? will the total momentum and kinetic energy be conserved as they pass out of the box on one side and into the box on the opposite site?
-There is also the old dos game asteroids which implements periodic boundary conditions quite nice:-)
The biggest issue in your subsequent simulation won't be the periodicity of the box -- it will be trying to equilibrate your system down from what looks like a tangle of lipids into an orderly structure. That can happen in a simulation, but (1) it may not, depending on initial condition (2) it's wasting computer time to arrive at a foregone conclusion.
Most lipid bilayer simulations use a software like Packmol to pre-arrange the lipid molecules into a suitable bilayer.