Skip to content

Commit e32dd04

Browse files
Merge pull request #249 from sayanbhowmik/master
2 parents 8a786e8 + 6424535 commit e32dd04

26 files changed

+1968
-9
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
-Date
33
-Name
44
-changes
5+
--------------
6+
July 17, 2025
7+
Name: Sayan Bhowmik
8+
Changes: src/include/isddft.h, src/initialization.c, src/readfiles.c, src/relax.c,
9+
tests/Al_pr_relax_comp, tests/Al_pr_relax_tens, tests/SPARC_testing_script.py,
10+
tests/README.md, doc/.LaTeX/Introduction.tex, doc/.LaTeX/Optimization.tex,doc/Manual.pdf
11+
1. Added target pressure for cell relaxation.
12+
513
--------------
614
June 17, 2025
715
Name: Tian Tian

doc/.LaTeX/Introduction.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
\item \textbf{Tian Tian}: Socket communication layer, code testing, Python API
5454
\item \textbf{Lucas R Timmerman\footnotemark[2]}: Socket communication layer, code testing, Python API
5555
\end{itemize}
56-
\end{itemize}
56+
\end{itemize}
5757
\footnotetext[1]{co-advised with Andrew J. Medford}
5858
\footnotetext[2]{co-advised with Phanish Suryanarayana}
5959
\end{frame}
@@ -378,7 +378,7 @@
378378
\hyperlink{RELAX_METHOD}{\texttt{RELAX\_METHOD}} $\vert$
379379
\hyperlink{RELAX_NITER}{\texttt{RELAX\_NITER}} $\vert$
380380
\hyperlink{TOL_RELAX}{\texttt{TOL\_RELAX}} $\vert$
381-
\hyperlink{TOL_RELAX_CELL}{\texttt{TOL\_RELAX\_CELL}} $\vert$
381+
\hyperlink{TOL_RELAX_CELL}{\texttt{TOL\_RELAX\_CELL}} $\vert$ \hyperlink{RELAX_PRESSURE}{\texttt{RELAX\_PRESSURE}} $\vert$
382382
\hyperlink{RELAX_MAXDILAT}{\texttt{RELAX\_MAXDILAT}} $\vert$
383383
\hyperlink{NLCG_SIGMA}{\texttt{NLCG\_SIGMA}} $\vert$
384384
\hyperlink{L_HISTORY}{\texttt{L\_HISTORY}} $\vert$

doc/.LaTeX/Optimization.tex

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,38 @@
185185
\end{frame}
186186
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187187

188+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189+
\begin{frame}[allowframebreaks]{\texttt{RELAX\_PRESSURE}} \label{RELAX_PRESSURE}
190+
\vspace*{-12pt}
191+
\begin{columns}
192+
\column{0.4\linewidth}
193+
\begin{block}{Type}
194+
Double
195+
\end{block}
196+
197+
\begin{block}{Default}
198+
0.0
199+
\end{block}
200+
201+
\column{0.4\linewidth}
202+
\begin{block}{Unit}
203+
GPa
204+
\end{block}
205+
206+
\begin{block}{Example}
207+
\texttt{RELAX\_PRESSURE}: 4.53
208+
\end{block}
209+
\end{columns}
210+
211+
\begin{block}{Description}
212+
Specifies the target outer pressure for cell volume relaxation - \hyperlink{RELAX_FLAG}{\texttt{RELAX\_FLAG}}: 2 or \hyperlink{RELAX_FLAG}{\texttt{RELAX\_FLAG}}: 3.
213+
\end{block}
214+
215+
%\begin{block}{Remark}
216+
%\end{block}
217+
218+
\end{frame}
219+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188220

189221
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190222
\begin{frame}[allowframebreaks]{\texttt{RELAX\_MAXDILAT}} \label{RELAX_MAXDILAT}

doc/Manual.pdf

3.97 KB
Binary file not shown.

src/include/isddft.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ typedef struct _SPARC_OBJ{
857857
double qmass; // mass parameter
858858
double amu2au; // conversion factor for atomic mass unit -> atomic unit of mass
859859
double fs2atu; // conversion factor for femto second -> atomic unit of time (Jiffy)
860+
double relaxPrTarget; // Target pressure for cell relaxation in GPa
860861
// NPT
861862
int NPTscaleVecs[3]; // which lattice vector can be rescaled?
862863
int NPTconstraintFlag; // confinement on side length of cell. none: no length confinement (default); 1: a:b keeps unchanged; 2: a:c keeps unchanged;
@@ -1349,6 +1350,7 @@ typedef struct _SPARC_INPUT_OBJ{
13491350
int L_history;
13501351
int L_autoscale;
13511352
int L_lineopt;
1353+
double relaxPrTarget; // Target pressure for cell relaxation in GPa
13521354

13531355
/* Stress options*/
13541356
int Calc_stress;

src/initialization.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
#define min(x,y) ((x)<(y)?(x):(y))
5656
#define max(x,y) ((x)>(y)?(x):(y))
5757

58-
#define N_MEMBR 209
59-
// #define N_MEMBR 208
58+
#define N_MEMBR 210
6059

6160

6261
/**
@@ -856,6 +855,7 @@ void set_defaults(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC) {
856855
/* Default cell relaxation parameters*/
857856
pSPARC_Input->max_dilatation = 1.06; // maximum lattice dilatation
858857
pSPARC_Input->TOL_RELAX_CELL = 1e-2; // in GPa (all periodic)
858+
pSPARC_Input->relaxPrTarget = 0; // Default relaxation pressure in 0 GPa
859859

860860
/* Default band structure calculation parameters */
861861
pSPARC_Input->BandStructFlag = 0;
@@ -1575,6 +1575,7 @@ void SPARC_copy_input(SPARC_OBJ *pSPARC, SPARC_INPUT_OBJ *pSPARC_Input) {
15751575
pSPARC->OFDFT_lambda = pSPARC_Input->OFDFT_lambda;
15761576
pSPARC->twist = pSPARC_Input->twist;
15771577
pSPARC->is_hubbard = pSPARC_Input->is_hubbard; // DFT+U
1578+
pSPARC->relaxPrTarget = pSPARC_Input->relaxPrTarget; // Target pressure for cell relaxation
15781579

15791580
// char type values
15801581
strncpy(pSPARC->MDMeth , pSPARC_Input->MDMeth,sizeof(pSPARC->MDMeth));
@@ -1704,7 +1705,7 @@ void SPARC_copy_input(SPARC_OBJ *pSPARC, SPARC_INPUT_OBJ *pSPARC_Input) {
17041705
if (pSPARC->BandStructFlag == 1) {
17051706
pSPARC->MAXIT_SCF = 1;
17061707
pSPARC->MINIT_SCF = 1;
1707-
if (pSPARC->is_hubbard) pSPARC->MAXIT_SCF = 50;
1708+
// if (pSPARC->is_hubbard) pSPARC->MAXIT_SCF = 50; // need to work on hubbard band
17081709
pSPARC->PrintElecDensFlag = 0;
17091710
pSPARC->PrintEigenFlag = 1;
17101711
}
@@ -3856,6 +3857,10 @@ void write_output_init(SPARC_OBJ *pSPARC) {
38563857
}
38573858
}
38583859

3860+
if (pSPARC->RelaxFlag > 1) {
3861+
fprintf(output_fp,"RELAX_PRESSURE: %.15g\n",pSPARC->relaxPrTarget);
3862+
}
3863+
38593864
fprintf(output_fp,"CALC_STRESS: %d\n",pSPARC->Calc_stress);
38603865
if(pSPARC->Calc_stress == 0)
38613866
fprintf(output_fp,"CALC_PRES: %d\n",pSPARC->Calc_pres);
@@ -4355,6 +4360,7 @@ void SPARC_Input_MPI_create(MPI_Datatype *pSPARC_INPUT_MPI) {
43554360
MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE,
43564361
MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE,
43574362
MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE,
4363+
MPI_DOUBLE,
43584364
MPI_CHAR, MPI_CHAR, MPI_CHAR, MPI_CHAR, MPI_CHAR,
43594365
MPI_CHAR, MPI_CHAR, MPI_CHAR, MPI_CHAR, MPI_CHAR};
43604366
int blens[N_MEMBR] = {3, 3, 7, /* int array */
@@ -4397,7 +4403,7 @@ void SPARC_Input_MPI_create(MPI_Datatype *pSPARC_INPUT_MPI) {
43974403
1, 1, 1, 1, 1,
43984404
1, 1, 1, 1, 1,
43994405
1, 1, 1, 1, 1,
4400-
1, /* double */
4406+
1, 1, /* double */
44014407
32, 32, 32, L_STRING, L_STRING, /* char */
44024408
L_STRING, L_STRING, L_STRING, L_STRING, L_STRING};
44034409

@@ -4611,6 +4617,8 @@ void SPARC_Input_MPI_create(MPI_Datatype *pSPARC_INPUT_MPI) {
46114617
MPI_Get_address(&sparc_input_tmp.xi_3_SOAP, addr + i++);
46124618
MPI_Get_address(&sparc_input_tmp.F_tol_SOAP, addr + i++);
46134619
MPI_Get_address(&sparc_input_tmp.F_rel_scale, addr + i++);
4620+
4621+
MPI_Get_address(&sparc_input_tmp.relaxPrTarget, addr + i++);
46144622

46154623

46164624
// char type

src/readfiles.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,9 @@ void read_input(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC) {
10141014
fscanf(input_fp, "%*[^\n]\n");
10151015
} else if(strcmpi(str,"HUBBARD_FLAG:") == 0) {
10161016
fscanf(input_fp,"%d",&pSPARC_Input->is_hubbard);
1017+
} else if (strcmpi(str,"RELAX_PRESSURE:") == 0) {
1018+
fscanf(input_fp,"%lf",&pSPARC_Input->relaxPrTarget); // input in GPa
1019+
fscanf(input_fp, "%*[^\n]\n");
10171020
} else {
10181021
printf("\nCannot recognize input variable identifier: \"%s\"\n",str);
10191022
exit(EXIT_FAILURE);

src/relax.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,11 @@ double volrelax_constraint(SPARC_OBJ *pSPARC, double vol)
10711071
// free memory
10721072
free(stress_lc);
10731073

1074-
// return max pressure stress
1075-
return max_P_stress;
1074+
// return max pressure stress - target relaxation pressure
1075+
#ifdef DEBUG
1076+
if (rank == 0) printf("\n\n CELL_RELAX residual = %6.6f\n\n",-max_P_stress - pSPARC->relaxPrTarget);
1077+
#endif
1078+
return (-max_P_stress - pSPARC->relaxPrTarget);
10761079
}
10771080

10781081

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
LATVEC_SCALE: 1 1 1
3+
LATVEC:
4+
7.628635126863900 0.000000000000000 0.000000000000000
5+
0.000000000000000 7.628635126863900 0.000000000000000
6+
0.000000000000000 0.000000000000000 7.628635126863900
7+
BC: P P P
8+
9+
10+
EXCHANGE_CORRELATION: GGA_PBE
11+
12+
13+
MESH_SPACING: 0.3
14+
15+
KPOINT_GRID: 4 4 4
16+
17+
RELAX_FLAG: 2
18+
RELAX_PRESSURE: 1.0517108455E+01
19+
PRECOND_KERKER_THRESH: 0.0
20+
MIXING_PARAMETER: 1.0
21+
TOL_SCF: 1e-5
22+
23+
TOL_RELAX_CELL: 1e-4
24+
25+
CALC_STRESS: 1
26+
PRINT_ATOMS: 1
27+
PRINT_VELS: 0
28+
PRINT_FORCES: 1
29+
PRINT_EIGEN: 0
30+
PRINT_DENSITY: 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#=========================
2+
# format of ion file
3+
#=========================
4+
# ATOM_TYPE: <atom type name>
5+
# N_TYPE_ATOM: <num of atoms of this type>
6+
# COORD:
7+
# <xcoord> <ycoord> <zcoord>
8+
# ...
9+
# RELAX:
10+
# <xrelax> <yrelax> <zrelax>
11+
# ...
12+
13+
ATOM_TYPE: Al # atom type
14+
ATOMIC_MASS: 26.981539 # atomic mass (amu)
15+
PSEUDO_POT: ../../../psps/13_Al_3_1.9_1.9_pbe_n_v1.0.psp8 # pseudopotential file
16+
N_TYPE_ATOM: 4 # number of atoms of this type
17+
18+
COORD_FRAC: # fractional coordinates (in lattice vector basis)
19+
0 0 0
20+
0.500000000000000 0 0.500000000000000
21+
0 0.500000000000000 0.500000000000000
22+
0.500000000000000 0.500000000000000 0

0 commit comments

Comments
 (0)