The purpose of the project is to develop a flexible scheme for quantum-mechanical simimulations of the electronc structre of large molecules and periodic infinite systems such as crystals, implemented in a computer code. The simulations are to be carried out using self-consistent field theor: the Hartree-Fock independent-particle model and most important Kohn-Sham density-functional theory, the single most popular approach to the many-electron problem. An important feature of the proposed method is a very high degree of flexibility, both with respect to the systems that can be treated (small and large molcules, periodic or nonperiodic), the underlying physical description (relativistic or nonrelativistic), and the properties that can be treated (geometric , electromagnetic, linear or nonlinear, static or dynamic). The central task of is the development of a highly efficient and flexible code for the generation of the Fock and Kohn-Sham matrices, which represent the effective one-electron potentials for the electrons in the system. An essential requirement on the methods and the code is that of linear scaling: the cost of the calculations should be proportional to the size of the system. This requirment is nontrivial: because of the complicated many-partic le interactions in electronic systems, care must be taken to avoid a nonlinear scaling with system size. In the present project, we shall take advantage of the methods that have been developed over the last decade for linear scaling, developing these f urther and combining them with the know-how and technology already implemented in our own code Dalton for highly accurate calculations on small and medium-sized systems. The new code will provide a very useful set of tools for treating molecular systems a nd periodic systems, for the rigorous calculation of structure, excitation energies, nonlinear optical properties, and magnetic resonance parameters such as shielding constants and spin-spin cooupling constants.