Skip to content

Commit 3c05bd3

Browse files
authored
Merge pull request #7 from libefp2/syntax
dipquad dynamic polarizabilities are parsed from efp potential
2 parents 081216d + 25319ce commit 3c05bd3

4 files changed

Lines changed: 164 additions & 2 deletions

File tree

src/efp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ free_frag(struct frag *frag)
131131
free(frag->multipole_pts);
132132
free(frag->polarizable_pts);
133133
free(frag->dynamic_polarizable_pts);
134+
free(frag->dipquad_polarizable_pts);
134135
free(frag->lmo_centroids);
135136
free(frag->xr_fock_mat);
136137
free(frag->xr_wf);
@@ -204,6 +205,16 @@ copy_frag(struct frag *dest, const struct frag *src)
204205
memcpy(dest->dynamic_polarizable_pts,
205206
src->dynamic_polarizable_pts, size);
206207
}
208+
if (src->dipquad_polarizable_pts) {
209+
size = src->n_dipquad_polarizable_pts *
210+
sizeof(struct dipquad_polarizable_pt);
211+
dest->dipquad_polarizable_pts =
212+
(struct dipquad_polarizable_pt *)malloc(size);
213+
if (!dest->dipquad_polarizable_pts)
214+
return EFP_RESULT_NO_MEMORY;
215+
memcpy(dest->dipquad_polarizable_pts,
216+
src->dipquad_polarizable_pts, size);
217+
}
207218
if (src->lmo_centroids) {
208219
size = src->n_lmo * sizeof(vec_t);
209220
dest->lmo_centroids = (vec_t *)malloc(size);

src/mathutil.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ typedef struct {
4848
double xx, xy, xz, yx, yy, yz, zx, zy, zz;
4949
} mat_t;
5050

51+
typedef struct {
52+
double xxx, xxy, xxz, xyx, xyy, xyz, xzx, xzy, xzz,
53+
yxx, yxy, yxz, yyx, yyy, yyz, yzx, yzy, yzz,
54+
zxx, zxy, zxz, zyx, zyy, zyz, zzx, zzy, zzz;
55+
} t3_t;
56+
5157
static const vec_t vec_zero = { 0.0, 0.0, 0.0 };
5258

5359
static const six_t six_zero = { 0.0, 0.0, 0.0,

src/parse.c

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,139 @@ skip_ctfok(struct frag *frag, struct stream *stream)
695695
return EFP_RESULT_SUCCESS;
696696
}
697697

698+
static enum efp_result
699+
parse_dipquad_polarizable_pts(struct frag *frag, struct stream *stream)
700+
{
701+
double m[27];
702+
703+
efp_stream_next_line(stream);
704+
705+
while (!efp_stream_eof(stream)) {
706+
frag->n_dipquad_polarizable_pts++;
707+
708+
size_t size = sizeof(struct dipquad_polarizable_pt);
709+
frag->dipquad_polarizable_pts =
710+
(struct dipquad_polarizable_pt *)realloc(
711+
frag->dipquad_polarizable_pts,
712+
frag->n_dipquad_polarizable_pts * size);
713+
if (frag->dipquad_polarizable_pts == NULL)
714+
return EFP_RESULT_NO_MEMORY;
715+
716+
struct dipquad_polarizable_pt *pt =
717+
frag->dipquad_polarizable_pts +
718+
frag->n_dynamic_polarizable_pts - 1;
719+
720+
if (!efp_stream_advance(stream, 5))
721+
return EFP_RESULT_SYNTAX_ERROR;
722+
723+
if (!tok_double(stream, &pt->x) ||
724+
!tok_double(stream, &pt->y) ||
725+
!tok_double(stream, &pt->z))
726+
return EFP_RESULT_SYNTAX_ERROR;
727+
728+
efp_stream_next_line(stream);
729+
730+
for (size_t j = 0; j < 27; j++)
731+
if (!tok_double(stream, m + j))
732+
return EFP_RESULT_SYNTAX_ERROR;
733+
734+
//tentative order!!!
735+
pt->tensor[0].xxx = m[0];
736+
pt->tensor[0].xxy = m[1];
737+
pt->tensor[0].xxz = m[2];
738+
pt->tensor[0].xyx = m[3];
739+
pt->tensor[0].xyy = m[4];
740+
pt->tensor[0].xyz = m[5];
741+
pt->tensor[0].xzx = m[6];
742+
pt->tensor[0].xzy = m[7];
743+
pt->tensor[0].xzz = m[8];
744+
pt->tensor[0].yxx = m[9];
745+
pt->tensor[0].yxy = m[10];
746+
pt->tensor[0].yxz = m[11];
747+
pt->tensor[0].yyx = m[12];
748+
pt->tensor[0].yyy = m[13];
749+
pt->tensor[0].yyz = m[14];
750+
pt->tensor[0].yzx = m[15];
751+
pt->tensor[0].yzy = m[16];
752+
pt->tensor[0].yzz = m[17];
753+
pt->tensor[0].zxx = m[18];
754+
pt->tensor[0].zxy = m[19];
755+
pt->tensor[0].zxz = m[20];
756+
pt->tensor[0].zyx = m[21];
757+
pt->tensor[0].zyy = m[22];
758+
pt->tensor[0].zyz = m[23];
759+
pt->tensor[0].zzx = m[24];
760+
pt->tensor[0].zzy = m[25];
761+
pt->tensor[0].zzz = m[26];
762+
763+
efp_stream_next_line(stream);
764+
765+
if (efp_stream_eof(stream))
766+
return EFP_RESULT_SYNTAX_ERROR;
767+
768+
if (strstr(efp_stream_get_ptr(stream), "FOR"))
769+
break;
770+
}
771+
if (efp_stream_eof(stream))
772+
return EFP_RESULT_SYNTAX_ERROR;
773+
774+
for (size_t w = 1; w < 12; w++) {
775+
for (size_t i = 0; i < frag->n_dipquad_polarizable_pts; i++) {
776+
struct dipquad_polarizable_pt *pt =
777+
frag->dipquad_polarizable_pts + i;
778+
779+
if (!efp_stream_advance(stream, 5))
780+
return EFP_RESULT_SYNTAX_ERROR;
781+
//printf("\n in dipquad 8");
782+
if (!tok_double(stream, &pt->x) ||
783+
!tok_double(stream, &pt->y) ||
784+
!tok_double(stream, &pt->z))
785+
return EFP_RESULT_SYNTAX_ERROR;
786+
787+
efp_stream_next_line(stream);
788+
//printf("\n in dipquad 9");
789+
for (size_t j = 0; j < 27; j++)
790+
if (!tok_double(stream, m + j))
791+
return EFP_RESULT_SYNTAX_ERROR;
792+
793+
pt->tensor[w].xxx = m[0];
794+
pt->tensor[w].xxy = m[1];
795+
pt->tensor[w].xxz = m[2];
796+
pt->tensor[w].xyx = m[3];
797+
pt->tensor[w].xyy = m[4];
798+
pt->tensor[w].xyz = m[5];
799+
pt->tensor[w].xzx = m[6];
800+
pt->tensor[w].xzy = m[7];
801+
pt->tensor[w].xzz = m[8];
802+
pt->tensor[w].yxx = m[9];
803+
pt->tensor[w].yxy = m[10];
804+
pt->tensor[w].yxz = m[11];
805+
pt->tensor[w].yyx = m[12];
806+
pt->tensor[w].yyy = m[13];
807+
pt->tensor[w].yyz = m[14];
808+
pt->tensor[w].yzx = m[15];
809+
pt->tensor[w].yzy = m[16];
810+
pt->tensor[w].yzz = m[17];
811+
pt->tensor[w].zxx = m[18];
812+
pt->tensor[w].zxy = m[19];
813+
pt->tensor[w].zxz = m[20];
814+
pt->tensor[w].zyx = m[21];
815+
pt->tensor[w].zyy = m[22];
816+
pt->tensor[w].zyz = m[23];
817+
pt->tensor[w].zzx = m[24];
818+
pt->tensor[w].zzy = m[25];
819+
pt->tensor[w].zzz = m[26];
820+
821+
efp_stream_next_line(stream);
822+
}
823+
}
824+
printf("\n in dipquad 10");
825+
if (!tok_stop(stream))
826+
return EFP_RESULT_SYNTAX_ERROR;
827+
828+
return EFP_RESULT_SUCCESS;
829+
}
830+
698831
static enum efp_result
699832
parse_screen(struct frag *frag, struct stream *stream)
700833
{
@@ -813,6 +946,7 @@ get_parse_fn(struct stream *stream)
813946
{ "CANONFOK", skip_canonfok },
814947
{ "CTVEC", skip_ctvec },
815948
{ "CTFOK", skip_ctfok },
949+
{ "DIPOLE-QUADRUPOLE DYNAMIC POLARIZABLE POINTS", parse_dipquad_polarizable_pts},
816950
{ "SCREEN", parse_screen },
817951
{ "XRFIT", parse_xrfit },
818952
{ "POLAB", parse_polab },

src/private.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ struct dynamic_polarizable_pt {
6161
mat_t tensor[12];
6262
};
6363

64+
struct dipquad_polarizable_pt {
65+
double x, y, z;
66+
t3_t tensor[12];
67+
};
68+
6469
struct ff_atom {
6570
char type[32]; /* atom type in force field */
6671
size_t idx; /* index in atoms array */
@@ -114,10 +119,16 @@ struct frag {
114119
/* dynamic polarizability points */
115120
struct dynamic_polarizable_pt *dynamic_polarizable_pts;
116121

117-
/* number of dynamic polarizability points */
122+
/* dipole-quadrupole dynamic polarizability points */
123+
struct dipquad_polarizable_pt *dipquad_polarizable_pts;
124+
125+
/* number of dynamic polarizability points */
118126
size_t n_dynamic_polarizable_pts;
119127

120-
/* number of localized molecular orbitals */
128+
/* number of dipole-quadrupole dynamic polarizability points */
129+
size_t n_dipquad_polarizable_pts;
130+
131+
/* number of localized molecular orbitals */
121132
size_t n_lmo;
122133

123134
/* localized molecular orbital centroids */

0 commit comments

Comments
 (0)