<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_aims(filename):
 """Method to read FHI-aims geometry files in phonopy context."""


    lines = open(filename, 'r').readlines()

    cell = []
    is_frac = []
    positions = []
    symbols = []
    magmoms = []
    for line in lines:
        fields = line.split()
        if not len(fields):
            continue
        if fields[0] == "lattice_vector":
            vec = lmap(float, fields[1:4])
            cell.append(vec)
        elif fields[0][0:4] == "atom":
            if fields[0] == "atom":
                frac = False
            elif fields[0] == "atom_frac":
                frac = True
            pos = lmap(float, fields[1:4])
            sym = fields[4]
            is_frac.append(frac)
            positions.append(pos)
            symbols.append(sym)
            magmoms.append(None)
        # implicitly assuming that initial_moments line adhere to FHI-aims geometry.in specification,
        # i.e. two subsequent initial_moments lines do not occur
        # if they do, the value specified in the last line is taken here - without any warning
        elif fields[0] == "initial_moment":
            magmoms[-1] = float(fields[1])

    for (n,frac) in enumerate(is_frac):
        if frac:
            pos = [ sum( [ positions[n][l] * cell[l][i] for l in range(3) ] ) for i in range(3) ]
            positions[n] = pos
    if None in magmoms:
        atoms = Atoms(cell=cell, symbols=symbols, positions=positions)
    else:
        atoms = Atoms(cell=cell, symbols=symbols, positions=positions, magmoms=magmoms)

    return atoms