dTSOLdx_i=-0.1*Tped_i/xwidth

TScale_z=1.0
Tped_z=0.9
dTCoredx_z=-0.1*Tped_i/xwidth
dTpeddx_z=-0.1*Tped_i/xwidth
dTSOLdx_z=-0.1*Tped_i/xwidth


nScale_i=1.0
nped_i=0.4
dnCoredx_i=-0.6
dnpeddx_i=-nped_i/xwidth
#print dnpeddx_d
dnSOLdx_i=-0.6

imp_conc=0.01


profile_params={"Tped_"+species[eI]:Tped_e,"dTCoredx_"+species[eI]:dTCoredx_e,"dTpeddx_"+species[eI]:dTpeddx_e,"dTSOLdx_"+species[eI]:dTSOLdx_e,"TScale_"+species[eI]:TScale_e,
                "Tped_"+species[mI]:Tped_i,"dTCoredx_"+species[mI]:dTCoredx_i,"dTpeddx_"+species[mI]:dTpeddx_i,"dTSOLdx_"+species[mI]:dTSOLdx_i,"TScale_"+species[mI]:TScale_i,
                "Tped_"+species[zI]:Tped_z,"dTCoredx_"+species[zI]:dTCoredx_z,"dTpeddx_"+species[zI]:dTpeddx_z,"dTSOLdx_"+species[zI]:dTSOLdx_z,"TScale_"+species[mI]:TScale_z,
                "nped_"+species[mI]:nped_i,"dnCoredx_"+species[mI]:dnCoredx_i,"dnpeddx_"+species[mI]:dnpeddx_i,"dnSOLdx_"+species[mI]:dnSOLdx_i,"nScale_"+species[mI]:nScale_i,}

grid_params={"nonuniform":True, "grid_type":"Int_arctan","transition_length":0.025, "pedestal_grid_density":0.9,"leftshift":20*0.025,"rightshift":20*0.025}

grid_profile_params=  dict(profile_params.items() + grid_params.items())


generate_compatible_profiles(simul,mI=mI,zI=zI,eI=eI,imp_conc=imp_conc,xwidth=xwidth,a=a,dxdpsiN=dxdpsiN,upShift_denom=upShift_denom,m2tanh=True,sameflux=True,mode="const_Phi",**grid_profile_params)
    "dTSOLdx_" + species[zI]: dTSOLdx_z,
    "TScale_" + species[mI]: TScale_z,
    "nped_" + species[mI]: nped_i,
    "dnCoredx_" + species[mI]: dnCoredx_i,
    "dnpeddx_" + species[mI]: dnpeddx_i,
    "dnSOLdx_" + species[mI]: dnSOLdx_i,
    "nScale_" + species[mI]: nScale_i,
}


Z = 2
c = float(1)
c0 = float(0.01)
profile_params["nScale_" + species[mI]] = (Z * c0 + 1) / (Z * c + 1)


generate_compatible_profiles(
    simul,
    mI=mI,
    zI=zI,
    eI=eI,
    imp_conc=c,
    xwidth=xwidth,
    a=a,
    dxdpsiN=dxdpsiN,
    upShift_denom=upShift_denom,
    sameflux=False,
    m2tanh=True,
    **profile_params
)
nped_d=0.4
dnCoredx_d=-0.6
dnpeddx_d=-nped_d/xwidth
dnSOLdx_d=-0.6

cmd="perfect -ksp_type gmres -ksp_gmres_restart 100 -ksp_max_it 1000"

num_simuls=2
simuls=[0]*num_simuls
dir="NthetaScan"
simul_dir_names=[dir+str(x+1) for x in range(num_simuls)]

#changes to make to the inputfile
groupname="resolutionParameters"
paramname="Ntheta"
change=-2


for i in range(0,num_simuls):
    if i==0:
        simuls[0]=original_simul.copy_simulation_norm_to_dir(simul_dir_names[0])
    else:
        simuls[i]=simuls[i-1].copy_simulation_norm_to_dir(simul_dir_names[i])
        simul_manipulation(simuls[i],groupname,paramname,change)
        #example: raise pedestal gradient for the ion density (makes them less negative)
        #dnpeddx_d=dnpeddx_d+0.2
    generate_compatible_profiles(simuls[i],mI=mI,zI=zI,eI=eI,imp_conc=imp_conc,xwidth=xwidth,a=a,dxdpsiN=dxdpsiN,Tped_e=Tped_e,dTCoredx_e=dTCoredx_e,dTpeddx_e=dTpeddx_e,dTSOLdx_e=dTSOLdx_e,Tped_d=Tped_d,dTCoredx_d=dTCoredx_d,dTpeddx_d=dTpeddx_d,dTSOLdx_d=dTSOLdx_d,Tped_N=Tped_N,dTCoredx_N=dTCoredx_N,dTpeddx_N=dTpeddx_N,dTSOLdx_N=dTSOLdx_N,nped_d=nped_d,dnCoredx_d=dnCoredx_d,dnpeddx_d=dnpeddx_d,dnSOLdx_d=dnSOLdx_d)
    simuls[i].always_run_simulation(cmd)