def makeFiles(sg):
    global cnt

    # mkdir
    os.system('mkdir -p ./lammps/%i' % cnt)

    #ff
    FF = read_ff_vary('/stokes/yuchen/PyMD/FORCEFIELDS/JC/TIP4P2005_q%i' % q,
                      config['ci'],
                      ep,
                      sg,
                      bonded=True)
    write_forcefield(
        './lammps/%i/in.forcefield' % cnt,
        'lj/cut/tip4p/long 1 2 1 1 0.1546 %.1f %.1f' % (rc, rc),  # functional
        atoms,
        bonds,
        angles,
        FF)  # input data

    # generate in.lammpsdata, directly cpy
    os.system('cp ./in.lammpsdata ./lammps/%i/' % cnt)

    # generate in.simulation
    os.system('cp ./in.simulation ./lammps/%i/' % cnt)

    # generate run.sh
    os.system('cp ./run.sh ./lammps/')
    cnt += 1
def tgFunc(sg, ep):

    global cnt, obs, data

    # ff
    FF = read_ff_vary('/stokes/yuchen/PyMD/FORCEFIELDS/JC/TIP4P2005_q%i' % q,
                      config['ele'],
                      10**ep,
                      sg,
                      bonded=True)
    write_forcefield(
        '%s/in.forcefield' % loc,
        'lj/cut/tip4p/long 1 2 1 1 0.1546 %.1f %.1f' % (rc, rc),  # functional
        atoms,
        bonds,
        angles,
        FF)  # input data

    # lammpsdata, simulation, lambds
    os.system('cp in.lammpsdata %s' % loc)
    os.system('cp in.simulation %s' % loc)
    os.system('cp in.lambdas %s' % loc)

    # run system, pp
    os.chdir(loc)
    os.system('mpirun -np 5 lmp_mpi -in in.simulation')
    os.chdir('../../')

    rio, cn = readRDF('%s/NaO.rdf' % loc)
    fN = transform(rio, tg)
    os.system('mkdir ./lammps/%i' % cnt)
    os.system('cp %s/* ./lammps/%i' % (loc, cnt))
    os.system('rm -rf %s/*' % loc)

    # if this function is called, then use global vaiable to record
    obs.append([cnt + 1, rio, sg, ep])
    obsArr = np.array(obs)
    obsErArr = obsArr.copy()
    obsErArr[:, 1] = -1 * transform(obsErArr[:, 1], tg)

    data['obs'] = obsArr
    data['obsEr'] = obsErArr
    data = {**config, **data}
    pickle.dump(data, open('data.pc', 'wb'))
    cnt += 1

    return fN