Home
Manual
Packages
Global Index
Keywords
Quick Reference
|
#include "Chris/gadget.i"
func AMR_read (noutput=,ncpu=,zcut=)
/* DOCUMENT
SEE ALSO:
*/
{
if (is_void(noutput)) noutput=3;
if (is_void(ncpu))
{
ncpu=0; sread,
format="%d",
splittok(exec("ls -1 amr_00001.out* | wc "))(1),ncpu;
}
fp= popen("/usr/local/rsi/idl_5.5/bin/idl ",1);
//fp= popen("idl",1);
fname=swrite(format="amr_%0.5i.out00001",noutput);
write,fname;
write,fp,"rd_amr,a,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
fname=swrite(format="hydro_%0.5i.out00001",noutput);
write,fp,"rd_hydro,h,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
fname=swrite(format="part_%0.5i.out00001",noutput);
write,fp,"rd_part,p,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
write,fp,"xr=[0.,a.nx]&& yr=[0.,a.ny] && zr=[0.,a.nz] \n";
write,fp,"amr2cell,a,h,c,xr=xr,yr=yr,zr=zr\n";fflush,fp;
write,fp,"dg=c.var(*,0) \n"; fflush,fp;
write,fp,"ug=c.var(*,1)*a.nx/a.boxlen \n"; fflush,fp;
write,fp,"vg=c.var(*,2)*a.nx/a.boxlen \n"; fflush,fp;
write,fp,"wg=c.var(*,3)*a.nx/a.boxlen \n"; fflush,fp;
write,fp,"pg=c.var(*,4)*c.dx^3*(a.nx/a.boxlen)^2 \n"; fflush,fp;
write,fp,"volg=c.dx^3 \n"; fflush,fp;
write,fp,"mg=dg*volg \n"; fflush,fp;
write,fp," print,max(pg);\n"; fflush,fp;
write,fp,"nn=size(c.x) && nn=nn(1) \n"; fflush,fp;
write,fp,"red=1./a.aexp-1. \n"; fflush,fp;
write,fp," print,'number of part',nn;\n"; fflush,fp;
write,fp," print,'redshift',red;\n"; fflush,fp;
write,fp,"openw,un,'._tmp_size.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,nn && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_redshift.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,red && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_posx.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,c.x && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_posy.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,c.y && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_posz.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,c.z && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_velx.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,ug && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_vely.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,vg && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_velz.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,wg && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_dens.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,dg && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_pres.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,pg && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_mass.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,mg && close,un&& free_lun,un\n";
close,fp;
np=0; _read,open("._tmp_size.dat","rb"),0,np;
red=float(0.); _read,open("._tmp_redshift.dat","rb"),0,red;
x=array(float,np); _read,open("._tmp_posx.dat","rb"),0,x;
y=array(float,np); _read,open("._tmp_posy.dat","rb"),0,y;
z=array(float,np); _read,open("._tmp_posz.dat","rb"),0,z;
vx=array(float,np); _read,open("._tmp_velx.dat","rb"),0,vx;
vy=array(float,np); _read,open("._tmp_vely.dat","rb"),0,vy;
vz=array(float,np); _read,open("._tmp_velz.dat","rb"),0,vz;
d=array(float,np); _read,open("._tmp_dens.dat","rb"),0,d;
p=array(double,np); _read,open("._tmp_pres.dat","rb"),0,p;
m=array(float,np); _read,open("._tmp_mass.dat","rb"),0,m;
system,"rm ./._tmp_*.dat";
q=GadgetSnapshot();
xyz=transpose([x,y,z]);
vel=transpose([vx,vy,vz]);
(q.pos)=&xyz;
(q.vel)=&vel;
(q.rho)=&d; (q.u)=&p; (q.mass)=&m;
q.npart=[np,0,0,0,0,0]; q.redshift=red;
id=indgen(np);
(q.id)=&id;
return q;
}
func AMR_DM_read (noutput=,ncpu=,zcut=)
/* DOCUMENT
reads the DM particles only
SEE ALSO:
*/
{
if (is_void(noutput)) noutput=3;
if (is_void(ncpu))
{
ncpu=0; sread,
format="%d",
splittok(exec("ls -1 amr_00001.out* | wc "))(1),ncpu;
}
fp= popen("/usr/local/rsi/idl_5.5/bin/idl",1);
//fp= popen("idl",1);
fname=swrite(format="amr_%0.5i.out00001",noutput);
write,fname;
fname=swrite(format="part_%0.5i.out00001",noutput);
write,fp,"rd_part,p,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
write,fp,"nn=p.npart \n"; fflush,fp;
write,fp," print,'number of part',nn;\n"; fflush,fp;
write,fp,"openw,un,'._tmp_size.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,nn && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_pos.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,p.xp && close,un&& free_lun,un\n";
write,fp,"openw,un,'._tmp_vel.dat',/get_lun\n"; fflush,fp;
write,fp,"writeu,un,p.vp && close,un&& free_lun,un\n";
close,fp;
np=0; _read,open("._tmp_size.dat","rb"),0,np;
// red=float(0.); _read,open("._tmp_redshift.dat","rb"),0,red;
xyz=array(float,np,3); _read,open("._tmp_pos.dat","rb"),0,xyz;xyz=transpose(xyz);
vel=array(float,np,3); _read,open("._tmp_vel.dat","rb"),0,vel;vel=transpose(vel);
system,"rm ./._tmp_*.dat";
q=GadgetSnapshot();
(q.pos)=&xyz;
(q.vel)=&vel;
q.npart=[0,np,0,0,0,0]; //q.redshift=red;
id=indgen(np);
(q.id)=&id;
return q;
}
func AMRcutslice (&u,&p,&ux,&uy,&uz,noutput=,ncpu=,zcut=,npix=)
/* DOCUMENT
EXAMPLE: q=AMRcutslice(u,p,ux,uy,uz,noutput=1)
SEE ALSO:
*/
{
if (is_void(ncpu)) {
ncpu=0; sread,
format="%d",
splittok(exec("ls -1 amr_00001.out* | wc "))(1),ncpu;
}
if (is_void(noutput)) noutput=1;
if (is_void(zcut)) zcut=[0.5];
if (is_void(npix)) npix=1024;
u=array(0.,npix,npix,numberof(zcut));
p=array(0.,npix,npix,numberof(zcut));
ux=array(0.,npix,npix,numberof(zcut));
uy=array(0.,npix,npix,numberof(zcut));
uz=array(0.,npix,npix,numberof(zcut));
for(i=1;i<=numberof(zcut);i++)
{
fp= popen("/usr/local/rsi/idl_5.5/bin/idl",1);
fname=swrite(format="amr_%0.5i.out00001",noutput);
write,fname;
write,fp,"rd_amr,a,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
write,fp,"red=1./a.aexp-1. \n"; fflush,fp;
write,fp," print,'number of part',nn;\n"; fflush,fp;
write,fp," print,'redshift',red;\n"; fflush,fp;
fname=swrite(format="hydro_%0.5i.out00001",noutput);
write,fp,"rd_hydro,h,ncpu="+pr1(ncpu)+",file=\'"+fname+"\'\n";fflush,fp;
write,"DOING SLICE ,zcut="+pr1(zcut(i))+"\n";
write,fp,"slice_fits,a,h,c,zcut="+pr1(zcut(i))+",nim="+pr1(npix)+"\n";fflush,fp;
zcuts=swrite(format="%05d",long(npix*zcut(i))+1);
while(!open("vxkmsm1_slice.zcut_"+zcuts+".dat","r",1)) {}
while(!open("vykmsm1_slice.zcut_"+zcuts+".dat","r",1)) {}
while(!open("vzkmsm1_slice.zcut_"+zcuts+".dat","r",1)) {}
while(!open("density_slice.zcut_"+zcuts+".dat","r",1)) {}
while(!open("pressure_slice.zcut_"+zcuts+".dat","r",1)) {}
u1=array(0.,npix,npix); _read,open("density_slice.zcut_"+zcuts+".dat","rb"),0,u1;
p1=array(0.,npix,npix); _read,open("pressure_slice.zcut_"+zcuts+".dat","rb"),0,p1;
ux1=array(0.,npix,npix); _read,open("vxkmsm1_slice.zcut_"+zcuts+".dat","rb"),0,ux1;
uy1=array(0.,npix,npix); _read,open("vykmsm1_slice.zcut_"+zcuts+".dat","rb"),0,uy1;
uz1=array(0.,npix,npix); _read,open("vzkmsm1_slice.zcut_"+zcuts+".dat","rb"),0,uz1;
u(,,i)=u1;
p(,,i)=p1;
ux(,,i)=ux1;
uy(,,i)=uy1;
uz(,,i)=uz1;
remove,"density_slice.zcut_"+zcuts+".dat";
remove,"density_slice.zcut_"+zcuts+".dat";
remove,"pressure_slice.zcut_"+zcuts+".dat";
remove,"vxkmsm1_slice.zcut_"+zcuts+".dat";
remove,"vykmsm1_slice.zcut_"+zcuts+".dat";
remove,"vzkmsm1_slice.zcut_"+zcuts+".dat";
close,fp;
}
}
|