How to change boundary conditions - cmyoo/cosmos GitHub Wiki
Tutorial 2: changing boundary conditions
We suppose Tutorial 1 has already been solved. Then, let us continue using the directory /sample/adiabatic_spheroid, which was made at the beginning of Tutorial 1.
Preliminary
Let us slightly change the function void Fmv::set_Psi_spheroid(double mu,double kk,double xi2) as follows
Namely,
$$ \zeta=-2\ln \Psi=-\mu\left[\exp\left(-\frac{1}{6}k^2 \left((X-q)^2+Y^2+Z^2\right)\right)\right]W(R). $$
We note that this configuration is NOT compatible with the default settings of the boundary conditions.
To make it compatible with boundary conditions, we employ the reflection boundary condition also for the $x$-direction:
How to edit files
Editting /adiabatic_spheroid/cosmos_boundary.cpp
-
List of functions needed to be modified:
void boundary_quarter();
void boundary_d_quarter();
void boundary_quarter_even(int i);
void boundary_prim_quarter();
void boundary_quarter_excflags();
void boundary_quarter_hflags();
void boundary_psi_initial_quarter();
void boundary_quarter_fluid();
void boundary_quarter_scalar();
void boundary_reflection();
void boundary_d_reflection();
void boundary_reflection_even(int i);
void boundary_prim_reflection();
void boundary_reflection_hflags();
void boundary_psi_initial();
void boundary_reflection_fluid();
void boundary_reflection_scalar(); -
How to modify
Since the modification is needed only for the boundary condition across the plane of $y=0$, the lines includingkl[k]have to be modified. Since the partner of the identification changes to have the opposite sign of the $x$-coordinate, the sign of the index specifying the grid number of the $x$-direction should be flipped. For vector and tensor variables, additional sign flips associated with the rotation around the $z$-axis should also be eliminated. For example, the following modifications have to be made for all lines includingkl[k]:
Editting /source/ahf2d.h $\longrightarrow$ /adiabatic_spheroid/ahf2d.h
Boundary conditions for the apparent horizon finder should also be modified if one needs to find an apparent horizon. The necessary modifications are indicated below.
-
Turn on the following code lines:
-
Change the boundary condition in the beginning of the Poisson solver:
-
Turn off the following code lines:
-
Change the last boundary setting:
-
One can check whether the apparent horizon finder works by setting the parameter value for continue to 1 in
par_ini.d, which enables one to run the program from the initial data stored inini_all.dat. Then the initial data is compatible with the new boundary conditions, and one can find an apparent horizon in the initial data through the apparent horizon finder if the modifications are appropriate.
How to run
-
You may create
/adiabatic_spheroiddirectory at the top of the COSMOS directory by doing the command as
./makecosmos.sh adiabatic_spheroid.
If the/adiabatic_spheroiddirectory is created successfully at the top of the COSMOS directory, you are ready to compile and run. -
The last step is to move to the
/adiabatic_spheroiddirectory ascd adiabatic_spheroid, domakethere, and run the executable output as./cosmos.