86extern gchar *
wnpos[3];
90extern void sort (
int dim,
int * tab);
107gchar *
cif_coord_opts[40][2] = {{
"b1",
"Monoclinic unique axis b, cell choice 1, abc"},
108 {
"b2",
"Monoclinic unique axis b, cell choice 2, abc"},
109 {
"b3",
"Monoclinic unique axis b, cell choice 3, abc"},
110 {
"-b1",
"Monoclinic unique axis b, cell choice 1, c-ba"},
111 {
"-b2",
"Monoclinic unique axis b, cell choice 2, c-ba"},
112 {
"-b3",
"Monoclinic unique axis b, cell choice 3, c-ba"},
113 {
"c1",
"Monoclinic unique axis c, cell choice 1, abc"},
114 {
"c2",
"Monoclinic unique axis c, cell choice 2, abc"},
115 {
"c3",
"Monoclinic unique axis c, cell choice 3, abc"},
116 {
"-c1",
"Monoclinic unique axis c, cell choice 1, ba-c"},
117 {
"-c2",
"Monoclinic unique axis c, cell choice 2, ba-c"},
118 {
"-c3",
"Monoclinic unique axis c, cell choice 3, ba-c"},
119 {
"a1",
"Monoclinic unique axis a, cell choice 1, abc"},
120 {
"a2",
"Monoclinic unique axis a, cell choice 2, abc"},
121 {
"a3",
"Monoclinic unique axis a, cell choice 3, abc"},
122 {
"-a1",
"Monoclinic unique axis a, cell choice 1, -acb"},
123 {
"-a2",
"Monoclinic unique axis a, cell choice 2, -acb"},
124 {
"-a3",
"Monoclinic unique axis a, cell choice 3, -acb"},
125 {
"abc",
"Orthorhombic"},
126 {
"ba-c",
"Orthorhombic"},
127 {
"cab",
"Orthorhombic"},
128 {
"-cba",
"Orthorhombic"},
129 {
"bca",
"Orthorhombic"},
130 {
"a-cb",
"Orthorhombic"},
131 {
"1abc",
"Orthorhombic origin choice 1"},
132 {
"1ba-c",
"Orthorhombic origin choice 1"},
133 {
"1cab",
"Orthorhombic origin choice 1"},
134 {
"1-cba",
"Orthorhombic origin choice 1"},
135 {
"1bca",
"Orthorhombic origin choice 1"},
136 {
"1a-cb",
"rthorhombic origin choice 1"},
137 {
"2abc",
"Orthorhombic origin choice 2"},
138 {
"2ba-c",
"Orthorhombic origin choice 2"},
139 {
"2cab",
"Orthorhombic origin choice 2"},
140 {
"2-cba",
"Orthorhombic origin choice 2"},
141 {
"2bca",
"Orthorhombic origin choice 2"},
142 {
"2a-cb",
"Orthorhombic origin choice 2"},
143 {
"1",
"Tetragonal or cubic origin choice 1"},
144 {
"2",
"Tetragonal or cubic origin choice 2"},
145 {
"h",
"Trigonal using hexagonal axes"},
146 {
"r",
"Trigonal using rhombohedral axes "}};
166 {
"model_fract_x",
"model_fract_y",
"model_fract_z"}};
168 {
"model_cartn_x",
"model_cartn_y",
"model_cartn_z"},
169 {
"pdbx_model_cartn_x_ideal",
"pdbx_model_cartn_y_ideal",
"pdbx_model_cartn_z_ideal"}};
178 typedef intptr_t ssize_t;
180 ssize_t getline(
char **lineptr,
size_t *n, FILE *stream)
185 if (lineptr == NULL || stream == NULL || n == NULL)
192 if (c == EOF)
return -1;
194 if (*lineptr == NULL)
196 *lineptr = malloc(128);
197 if (*lineptr == NULL)
return -1;
206 size_t new_size = *n + (*n >> 2);
211 char *new_ptr = realloc(*lineptr, new_size);
212 if (new_ptr == NULL)
return -1;
217 ((
unsigned char *)(*lineptr))[pos ++] = c;
218 if (c ==
'\n')
break;
222 (*lineptr)[pos] =
'\0';
252 gchar * init = g_strdup_printf (
"%s", line);
253 char * co_word = strtok_r (init,
" ", & co_line);
255 for (i=0; i<mid-1; i++)
257 co_word = strtok_r (NULL,
" ", & co_line);
275 gchar * init = g_strdup_printf (
"%s", line);
276 char * at_word = strtok_r (init,
" ", & at_line);
278 for (i=0; i<lid-1; i++) at_word = strtok_r (NULL,
" ", & at_line);
282 str = g_strdup_printf (
"%d", i);
290 return g_strdup_printf (
"%c%c", at_word[0], tolower(at_word[1]));
304 gchar * init = g_strdup_printf (
"%s", line);
305 char * wy_word = strtok_r (init,
" ", & wy_line);
308 for (i=0; i<wid-1; i++) wy_word = strtok_r (NULL,
" ", & wy_line);
332 gchar * init = g_strdup_printf (
"%s", line);
333 char * at_word = strtok_r (init,
" ", & at_line);
335 for (i=0; i<lid-1; i++) at_word = strtok_r (NULL,
" ", & at_line);
356 i = GPOINTER_TO_INT(data);
357 GtkTreeModel * cmodel = gtk_combo_box_get_model (
box);
360 gboolean done = TRUE;
361 if (gtk_combo_box_get_active_iter (
box, & iter))
363 gtk_tree_model_get_value (cmodel, & iter, 0, &
val);
364 str = g_strdup_printf (
"%s", (
char *)g_value_get_string (&
val));
372 if (! j) done = FALSE;
376 str = (done) ? g_strdup_printf (
APPLY) : g_strdup_printf (
DELETEB);
395 gchar * labpick = _(
"<b>To continue and build the crystal according to the information of the CIF file\n"
396 "it is required to provide a suitable value for each and every missing parameter(s).</b>"
397 "\n\nPlease select an atom type for the following object(s):");
401 GtkCellRenderer * renderer;
402 GtkTreeModel *
model;
408 str = g_strdup_printf (_(
"Type N°%d:\t<b>%s</b>"), i+1,
this_reader -> label[i]);
413 but = gtk_combo_box_new_with_model (
model);
414 g_object_unref (
model);
415 renderer = gtk_cell_renderer_combo_new ();
416 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (but), renderer, TRUE);
417 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (but), renderer,
"text", 0, NULL);
419 g_signal_connect (G_OBJECT(but),
"changed", G_CALLBACK(
set_cif_to_insert), GINT_TO_POINTER(i));
425 gchar * endpick = _(
"In case of a molecule: insert an extra type of atom and run a substitution afterwards.");
444 for (i=0; i<line_id; i++)
tail =
tail -> next;
465int cif_get_value (gchar * kroot, gchar * keyw,
int lstart,
int lend, gchar ** cif_word,
466 gboolean rec_val, gboolean all_ligne, gboolean total_num, gboolean record_position,
int * line_position)
472 gchar * str_w, * str_a, * str_b;
482 int numth = omp_get_max_threads ();
483 #pragma omp parallel for num_threads(numth) private(i,m,the_line,saved_line,the_word,mot,str_a,str_b,str_w) shared(j,k,l,this_reader,coord_line,cif_word,rec_val,all_ligne,kroot,keyw,total_num,record_position,line_position,res)
484 for (i=lstart; i<lend; i++)
487 if (
res && ! total_num)
goto endi;
488 the_line = g_strdup_printf (
"%s",
coord_line[i]);
489 the_word = strtok_r (the_line,
" ", & saved_line);
493 str_w = g_ascii_strdown (str_w, strlen(str_w));
494 if (strlen(str_w) == l)
496 str_a = g_strdup_printf (
"%c", str_w[0]);
497 for (m=1; m<j; m++) str_a = g_strdup_printf (
"%s%c", str_a, str_w[m]);
498 str_b = g_strdup_printf (
"%c", str_w[j+1]);
499 for (m=j+2; m<l; m++) str_b = g_strdup_printf (
"%s%c", str_b, str_w[m]);
500 if (g_strcmp0(str_a, kroot) == 0 && g_strcmp0(str_b,keyw) == 0)
502 the_word = strtok_r (NULL,
" ", & saved_line);
505 if (rec_val || all_ligne)
507 str = g_strdup_printf (_(
"Wrong file format: searching for <b>%s</b> - error at line <b>%d</b> !\n"), keyw, i+1);
523 line_position[
res] = i + 1;
535 mot = g_strdup_printf (
"%s", the_word);
536 the_word = strtok_r (NULL,
" ", & saved_line);
539 mot = g_strdup_printf (
"%s%s",
mot, the_word);
540 the_word = strtok_r (NULL,
" ", & saved_line);
542 the_word = g_strdup_printf (
"%s",
mot);
545 if (the_word && rec_val)
558 the_word = strtok_r (NULL,
" ", & saved_line);
571 the_line = g_strdup_printf (
"%s",
tail -> line);
572 the_word = strtok_r (the_line,
" ", & saved_line);
576 str_w = g_ascii_strdown (str_w, strlen(str_w));
577 if (strlen(str_w) == l)
579 str_a = g_strdup_printf (
"%c", str_w[0]);
580 for (m=1; m<j; m++) str_a = g_strdup_printf (
"%s%c", str_a, str_w[m]);
581 str_b = g_strdup_printf (
"%c", str_w[j+1]);
582 for (m=j+2; m<l; m++) str_b = g_strdup_printf (
"%s%c", str_b, str_w[m]);
583 if (g_strcmp0(str_a, kroot) == 0 && g_strcmp0(str_b,keyw) == 0)
585 the_word = strtok_r (NULL,
" ", & saved_line);
588 if (rec_val || all_ligne)
590 str = g_strdup_printf (_(
"Wrong file format: searching for <b>%s</b> - error at line <b>%d</b> !\n"), keyw, i+1);
603 mot = g_strdup_printf (
"%s", the_word);
604 the_word = strtok_r (NULL,
" ", & saved_line);
607 mot = g_strdup_printf (
"%s%s",
mot, the_word);
608 the_word = strtok_r (NULL,
" ", & saved_line);
610 the_word = g_strdup_printf (
"%s",
mot);
613 if (the_word && rec_val)
621 line_position[
res] = i + 1;
646 the_word = strtok_r (NULL,
" ", & saved_line);
666 gboolean
res = FALSE;
676 the_line = g_strdup_printf (
"%s",
coord_line[lid+i]);
677 the_word = strtok_r (the_line,
" ", & saved_line);
678 if (the_word[0] ==
'_')
699 the_line = g_strdup_printf (
"%s",
tail -> line);
700 the_word = strtok_r (the_line,
" ", & saved_line);
701 if (the_word[0] ==
'_')
736 for (i=lid-1; i>-1; i--)
738 the_line = g_strdup_printf (
"%s",
coord_line[i]);
739 the_word = strtok_r (the_line,
" ", & saved_line);
742 str_w = g_ascii_strdown (the_word, strlen(the_word));
756 the_line = g_strdup_printf (
"%s",
tail -> line);
757 the_word = strtok_r (the_line,
" ", & saved_line);
760 str_w = g_ascii_strdown (the_word, strlen(the_word));
793 steps =
cif_get_value (key_a, key_b, 0, linec, NULL, FALSE, FALSE, TRUE, TRUE, line_numbers);
798 gchar * str = g_strdup_printf (_(
"<b>CIF get loop line</b>: something is wrong for keyword: %s_%s\n"
799 " -> keyword found= %d times\n"
800 " -> configurations in CIF file= %d !\n"), key_a, key_b, steps,
this_reader -> steps);
803 g_free (line_numbers);
806 sort (steps, line_numbers);
807 lli = line_numbers[conf];
808 g_free (line_numbers);
813 lli =
cif_get_value (key_a, key_b, 0, linec, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
831gchar *
cif_retrieve_value (
int linec,
int conf, gchar * key_a, gchar * key_b, gboolean all_ligne, gboolean in_loop, gboolean warning)
834 gchar * cif_value = NULL;
842 steps =
cif_get_value (key_a, key_b, 0, linec, NULL, FALSE, FALSE, TRUE, TRUE, line_numbers);
848 str = g_strdup_printf (_(
"<b>CIF retrieved value</b>: keyword: %s_%s\n"
849 " -> keyword found= %d times\n"
850 " -> configurations in CIF file= %d !\n"), key_a, key_b, steps,
this_reader -> steps);
854 g_free (line_numbers);
858 sort (steps, line_numbers);
863 loop_pos[1] = (loop_pos[0] + 1000) > linec ? linec : (loop_pos[0] + 1000);
867 loop_pos[0] = (! line_numbers[conf]) ? line_numbers[conf] : line_numbers[conf] - 1;
868 loop_pos[1] = (loop_pos[0] + 1000) > linec ? linec : (loop_pos[0] + 1000);
871 g_free (line_numbers);
880 if (!
cif_get_value (key_a, key_b, loop_pos[0], loop_pos[1], & cif_value, TRUE, all_ligne, FALSE, FALSE, NULL) && warning)
883 g_debug (
"CIF:: retrieve:: keyword: %s_%s not found for conf %d between loop_pos[0]= %d and loop_pos[1]= %d\n", key_a, key_b, conf, loop_pos[0], loop_pos[1]);
885 str = g_strdup_printf (_(
"<b>Key positions</b>: keyword: %s_%s\n"
886 " -> not found for conf %d between loop_pos[0]= %d and loop_pos[1]= %d\n"), key_a, key_b, conf, loop_pos[0], loop_pos[1]);
905 gboolean
res = FALSE;
913 while (!
res && (lid+i) < linec)
915 the_line = g_strdup_printf (
"%s",
coord_line[lid+i]);
916 the_word = strtok_r (the_line,
" ", & saved_line);
920 if (! j) init = the_word[0];
922 the_word = strtok_r (NULL,
" ", & saved_line);
924 if (j == nelem && init !=
'_')
938 the_line = g_strdup_printf (
"%s",
tail -> line);
939 the_word = strtok_r (the_line,
" ", & saved_line);
943 if (j == 0) init = the_word[0];
945 the_word = strtok_r (NULL,
" ", & saved_line);
947 if (j == nelem && init !=
'_')
977 if (g_strcmp0(
this_reader -> label[i], stlab) == 0)
1026 gboolean done = TRUE;
1030 int numth = omp_get_max_threads ();
1031 #pragma omp parallel for num_threads(numth) private(i,j,v,cline,str) shared(this_reader,coord_line,at_step,done,lin,cid)
1034 cline = g_strdup_printf (
"%s",
coord_line[i+lin]);
1037 #pragma omp critical
1081 cline = g_strdup_printf (
"%s",
tail -> line);
1136 gchar * labkeys[2] = {
"type_symbol",
"label"};
1137 gchar * symkeys[4] = {
"wyckoff_symbol",
"occupancy",
"symmetry_multiplicity",
"disorder_group"};
1169 add_reader_info (_(
"<b>Atomic coordinates</b>: different sets of coordinate(s) were found.\n"
1170 "<b>atomes</b> will open each set of coordinate(s) in a separate model."), 1);
1213 for (j=0; j<
CFKEYS-1; j++)
1223 if (loop_line)
break;
1225 if (! loop_line)
return FALSE;
1250 add_reader_info (_(
"<b>Atomic coordinates</b>: different sets of coordinate(s) were found.\n"
1251 "<b>atomes</b> will open each set of coordinate(s) in a separate model."), 1);
1294 for (j=0; j<
CFKEYS-1; j++)
1304 if (loop_line)
break;
1306 if (! loop_line)
return FALSE;
1309 loop_max = (loop_line + 1000 > linec) ? linec : loop_line + 1000;
1313 cid[j] =
cif_get_value (
linekeys[lid], labkeys[j], loop_line, loop_max, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
1317 cid[j] -= loop_line;
1322 add_reader_info (_(
"<b>Atomic coordinates</b>: impossible to find atomic label(s) ..."), 0);
1330 cid[i+2] -= loop_line;
1334 str = g_strdup_printf (_(
"<b>Atomic coordinates</b>: impossible to find '%s' ..."), (
this_reader -> cartesian) ?
cartkeys[fid][i] :
frackeys[fid][i]);
1344 cid[i+5] =
cif_get_value (
linekeys[lid], symkeys[i], loop_line, loop_max, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
1347 cid[i+5] -= loop_line;
1369 str = g_strdup_printf (_(
"<b>Atomic coordinates</b>: the number of atom(s) changes !\n"
1370 " - configuration N°%d\t :: atoms= %d\n"
1409 for (k=i-1; k>-1; k--)
1411 if (tmp_z[k] <= v)
break;
1412 tmp_z[k+1] = tmp_z[k];
1413 tmp_nsps[k+1] = tmp_nsps[k];
1431 str = g_strdup_printf (_(
"<b>Atomic coordinates</b>: the number of chemical species changes !\n"
1432 " - configuration N°%d\t :: species= %d\n"
1443 str = g_strdup_printf (_(
"<b>Atomic coordinates</b>: the number of atom(s) for species %d changes !\n"
1444 " - configuration N°%d\t :: atom(s)= %d\n"
1445 " - initialization \t\t :: atom(s)= %d\n"), conf, i+1,
this_reader -> nsps[i],
cif_nsps[i]);
1470 add_reader_info (_(
"<b>Atomic coordinates</b>: a site has an occupancy > 1.0 !\n"), 0);
1485 gboolean new_occ, new_order;
1486 int occupancies = 1;
1490 num_occ[0] = num_order[0] = 1;
1493 new_occ = new_order = TRUE;
1494 for (j=0; j<occupancies; j++)
1505 test_occ = g_realloc (test_occ, (occupancies+1)*
sizeof*test_occ);
1507 u =
min (u, test_occ[occupancies]);
1508 v =
max (v, test_occ[occupancies]);
1509 num_occ = g_realloc (num_occ, (occupancies+1)*
sizeof*num_occ);
1510 num_occ[occupancies] = 1;
1513 for (j=0; j<disorders; j++)
1524 test_order = g_realloc (test_order, (disorders+1)*
sizeof*test_order);
1525 test_order[disorders] =
this_reader -> disorder[i];
1526 num_order = g_realloc (num_order, (disorders+1)*
sizeof*num_order);
1527 num_order[disorders] = 1;
1537 for (i=0; i<occupancies; i++)
1539 if (num_occ[i] !=
this_reader -> natomes/occupancies)
1548 for (i=0; i<disorders; i++)
1550 if (num_order[i] !=
this_reader -> natomes/disorders)
1571 gboolean
res = FALSE;
1579 the_line = g_strdup_printf (
"%s",
coord_line[lid+i]);
1582 the_line = g_strdup_printf (
"%s",
tail -> line);
1584 the_word = strtok_r (the_line,
" ", & saved_line);
1585 if (the_word[0] ==
'_' || g_strcmp0(the_word,
"loop_") == 0)
1601 gchar * sym_pos_line;
1606 sym_pos_line = g_strdup_printf (
"%s",
coord_line[lid+j]);
1609 sym_pos_line = g_strdup_printf (
"%s",
tail -> line);
1611 the_line = g_strdup_printf (
"%s", sym_pos_line);
1612 the_word = strtok_r (the_line,
" ", & saved_line);
1613 k_word = g_strdup_printf (
"%s", the_word);
1614 str = g_strdup_printf (
"%d", j+1);
1615 if (g_strcmp0(k_word, str) == 0)
1619 for (k=strlen(k_word); k<strlen(sym_pos_line); k++)
1623 the_line = g_strdup_printf (
"%c", sym_pos_line[k]);
1627 the_line = g_strdup_printf (
"%s%c", the_line, sym_pos_line[k]);
1633 the_line = g_strdup_printf (
"%s", sym_pos_line);
1637 g_free (sym_pos_line);
1641 the_word = strtok_r (the_line,
" ", & saved_line);
1644 this_reader -> sym_pos[j][k] = g_strdup_printf (
"%s", the_word);
1645 the_word = strtok_r (NULL,
" ", & saved_line);
1665 gchar * pos_key[2]={
"_symmetry_equiv_pos_as",
"_space_group_symop_operation"};
1674 line_id =
cif_get_value (pos_key[i],
"xyz", loop_line, linec, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
1678 if (! loop_line)
return FALSE;
1696 for (i=0; i<230; i++)
1699 if (g_strcmp0(str, hm) == 0)
1708 if (g_strcmp0(str, hm) == 0)
1718 for (i=0; i<230; i++)
1722 if (g_strrstr(str,
"-"))
1725 if (g_strcmp0(str, hm) == 0)
1760 str = g_strdup_printf (
"%s",
wnpos[1]);
1788 if (g_strcmp0(str, hmk) == 0)
1796 if (g_strcmp0(str, hmk) == 0 &&
this_reader ->
lattice.sp_group -> settings[j].origin == end+1)
1820 if (g_strcmp0(str, hmk) == 0)
1823 str = g_strdup_printf (_(
"<b>Space group</b>: CIF file information could be inaccurate !\n"
1824 " CIF file space group: <b>%s</b>, CIF file H-M symbol: <b>%s</b>\n"),
1833 if (g_strcmp0(str, hmk) == 0 &&
this_reader ->
lattice.sp_group -> settings[j].origin == end+1)
1836 str = g_strdup_printf (_(
"<b>Space group</b>: CIF file information could be inaccurate !\n"
1837 " CIF file space group: <b>%s</b>, CIF file H-M symbol: <b>%s</b>\n"),
1867 gchar * exts[2] = {
"h",
"r"};
1868 gchar * orig[2] = {
"1",
"2"};
1875 if (strstr(hmkey,
":"))
1877 key = g_strdup_printf (
"%s", hmkey);
1878 hmk = g_strdup_printf (
"%s", strtok (key,
":"));
1879 hma = g_strdup_printf (
"%s:", hmk);
1882 hmb = g_ascii_strdown (hmb, i);
1885 if (g_strcmp0(hmb, exts[i]) == 0)
1897 if (g_strcmp0(hmb, orig[i]) == 0)
1904 str = g_strdup_printf (_(
"<b>Space group</b>: CIF file information could be inaccurate !\n"
1905 " CIF file space group: <b>%s</b>, CIF file H-M symbol: <b>%s</b>\n"),
1921 hmk = g_strdup_printf (
"%s", hmkey);
1928 str = g_strdup_printf (_(
"<b>Space group</b>: CIF file information could be inaccurate !\n"
1929 " CIF file space group: <b>%s</b>, CIF file H-M symbol: <b>%s</b>\n"),
1935 return (spg) ? (j) ? j : spg : j;
1948 gchar * cellkeys[3] = {
"length_a",
"length_b",
"length_c"};
1949 gchar * cellangs[3] = {
"angle_alpha",
"angle_beta",
"angle_gamma",};
1962 str = g_strdup_printf (_(
"<b>Lattice parameters</b>: impossible to retrieve the '%s' parameter !\n"),
box_prop[0][j]);
1979 str = g_strdup_printf (_(
"<b>Lattice parameters</b>: impossible to retrieve the '%s' parameter !\n"),
box_prop[1][j]);
1991 g_debug (
"CIF:: angle[%d][%d]= %f", i, j,
this_reader ->
lattice.box[i].param[1][j]);
2010 gchar * symkey[2] = {
"int_tables_number",
"group_it_number"};
2026 str =
cif_retrieve_value (linec, conf,
"_space_group",
"it_number", TRUE, FALSE, FALSE);
2032 gchar * hmkey = NULL;
2034 hmkey =
cif_retrieve_value (linec, conf,
"_symmetry",
"space_group_name_h-m", TRUE, FALSE, FALSE);
2037 hmkey =
cif_retrieve_value (linec, conf,
"_symmetry",
"name_h-m_alt", TRUE, FALSE, FALSE);
2039 if (! hmkey && ! spg)
2041 add_reader_info (_(
"<b>Space group</b>: no space group and no H-M symbol found !\n"), 1);
2045 if (spg) g_debug (
"CIF:: Space group:: N°= %d, name= %s", spg,
groups[spg-1]);
2046 if (hmkey) g_debug (
"CIF:: H-M symbol:: %s", hmkey);
2057 add_reader_info (_(
"<b>Space group</b>: no space group found, unknown H-M symbol !\n"), 1);
2059 g_debug (
"CIF:: No space group found, unknown H-M symbol !");
2062 else if (spg && ! i)
2064 str = g_strdup_printf (_(
"<b>Space group</b>: space group and H-M symbol do not match !\n"
2065 " CIF file space group: <b>%s</b>, CIF file H-M symbol: <b>%s</b>\n"),
groups[spg-1], hmkey);
2069 g_debug (
"CIF:: Space group and H-M symbol do not match:: spg= %d, hm= %d", spg, i);
2072 else if (i && ! spg)
2085 str =
cif_retrieve_value (linec, conf,
"_space_group",
"it_coordinate_system_code", TRUE, FALSE, FALSE);
2089 for (i=0; i<40; i++)
2095 if (spg < 3 || spg > 15)
2103 str = g_strdup_printf (
"%c%c", str[0], str[1]);
2108 str = g_strdup_printf (
"%c", str[0]);
2116 if (g_strcmp0(lat, str) == 0) l ++;
2119 if (j < this_reader -> setting)
add_reader_info (_(
"<b>Space group</b>: ambiguous space group setting !\n"), 1);
2127 if (spg < 16 || spg > 74)
2133 if (str[0] ==
'1' || str[0]==
'2')
2141 lat = g_strdup_printf (
"%s%s%s",
2145 if (g_strcmp0(lat, str) == 0)
2147 if (j < this_reader -> setting ||
this_reader ->
lattice.sp_group -> settings[j].origin != k)
2149 add_reader_info (_(
"<b>Space group</b>: ambiguous space group setting !\n"), 1);
2156 if (! l)
add_reader_info (_(
"<b>Space group</b>: ambiguous space group setting !\n"), 1);
2160 if (spg < 75 || (spg > 142 && spg < 195))
2166 if (j < this_reader -> setting)
add_reader_info (_(
"<b>Space group</b>: ambiguous space group setting !\n"), 1);
2171 if (spg < 143 || spg > 165)
2177 if (j < this_reader -> setting)
add_reader_info (_(
"<b>Space group</b>: ambiguous space group setting !\n"), 1);
2185 if (spg > 142 && spg < 168)
2188 gboolean correct_this = FALSE;
2197 correct_this = TRUE;
2206 correct_this = TRUE;
2213 gchar * setc[2] = {
i18n(
"hexagonal"),
i18n(
"rhombohedral")};
2214 str = g_strdup_printf (_(
"<b>Space group</b>: found trigonal space group N°%d-%s, <b>%s</b> setting\n"
2215 "but the lattice parameters were found in <b>%s</b> format ...\n"
2216 "\t ... the space group setting was modified accordingly !\n"),
2228 str = g_strdup_printf (_(
"<b>Space group</b> and <b>lattice parameters</b> are not compatible !\n"
2229 "\nCheck a, b, c, and α, β, ɣ, with the type of crystal system.\n"));
2251 int i, j, k, l, m, n;
2279 g_debug (
"CIF:: SP group changes between configuration:: conf= %d, saved_group= %d, new_group= %d", conf,
saved_group, i);
2281 add_reader_info (_(
"Space group changes between configurations !\n"), 0);
2296 g_debug (
"CIF:: Impossible to retrieve space group information !");
2357 gchar * str = g_strdup_printf (_(
"<b>Building crystal using symmetry positions: </b> \n"
2358 " 1) evaluate candidate atomic positions using data in CIF file: \n"
2359 " - symmetry positions\n"
2360 " - atomic coordinates + occupancy\n"
2361 " 2) fill each candidate position using the associated occupancy: \n"
2368 double spgpos[3][4];
2370 gboolean dist_message = FALSE;
2371 gboolean low_occ = FALSE;
2374 gboolean * save_pos =
allocbool (max_pos);
2379 vec3_t * all_pos = g_malloc0(max_pos*
sizeof*all_pos);
2380 int * all_origin =
allocint (max_pos);
2383 double ** occ_pos = g_malloc0(
sizeof*occ_pos);
2384 int ** lot_pos = g_malloc0(
sizeof*lot_pos);
2399 for (j=i-1; j>-1; j--)
2401 if (list_occ[j] >=
val)
break;
2402 list_occ[j+1] = list_occ[j];
2403 list_pos[j+1] = list_pos[j];
2405 list_occ[j+1] =
val;
2406 list_pos[j+1] = vbl;
2421 for (l=0; l<3; l++) cryst_pos[num_pos][l] =
this_reader -> coord[k][l];
2422 cif_pos[num_pos] = 1;
2434 for (l=0; l<num_pos; l++)
2446 for (l=0; l<3; l++) cryst_pos[num_pos][l] =
this_reader -> coord[k][l];
2447 cif_pos[num_pos] = 1;
2463 pos_max =
max (pos_max, cif_pos[l]);
2475 for (i=0; i<num_pos; i++)
2478 for (j=0; j<cif_pos[i]; j++)
2510 pos_mat = mat4 (spgpos[0][0], spgpos[0][1], spgpos[0][2], spgpos[0][3],
2511 spgpos[1][0], spgpos[1][1], spgpos[1][2], spgpos[1][3],
2512 spgpos[2][0], spgpos[2][1], spgpos[2][2], spgpos[2][3],
2513 0.0, 0.0, 0.0, 1.0);
2514 for (j=0; j<num_pos; j++)
2516 f_pos = vec3 (cryst_pos[j][0], cryst_pos[j][1], cryst_pos[j][2]);
2517 f_pos = m4_mul_coord (pos_mat, f_pos);
2519 all_pos[l].
x = c_pos.
x;
2520 all_pos[l].
y = c_pos.
y;
2521 all_pos[l].
z = c_pos.
z;
2526 at.
x = all_pos[l].
x;
2527 at.
y = all_pos[l].
y;
2528 at.
z = all_pos[l].
z;
2531 bt.
x = all_pos[k].
x;
2532 bt.
y = all_pos[k].
y;
2533 bt.
z = all_pos[k].
z;
2535 if (
dist.length < 0.1)
2537 dist_message = TRUE;
2543 save_pos[l] = save_it;
2554 gboolean ** taken_pos = g_malloc0(num_pos*
sizeof*taken_pos);
2555 int ** site_lot = g_malloc0(num_pos*
sizeof*site_lot);
2558 for (i=0; i<num_pos; i++)
2561 site_lot[i] =
allocint (all_id[i]);
2562 for (j=0; j<cif_pos[i]; j++)
2564 u = occ_pos[i][j]*all_id[i];
2565 if (u < 1.0 && tot_pos < all_id[i]) u = 1.0;
2573 CPU_time = clock ();
2574 m = (CPU_time - (j+17)*all_id[i]);
2576 m = round (prob * (all_id[i]-1));
2577 pick_it = ! taken_pos[i][m];
2581 taken_pos[i][m] = TRUE;
2591 int * from_origin =
allocint (num_pos);
2592 for (j=0; j<max_pos; j++)
2598 if (taken_pos[k][l])
2600 cryst -> coord[i] = g_malloc0(
sizeof*cryst -> coord[i]);
2601 cryst -> coord[i][0].x = all_pos[j].
x;
2602 cryst -> coord[i][0].y = all_pos[j].
y;
2603 cryst -> coord[i][0].
z = all_pos[j].
z;
2604 cryst -> pos_by_object[i] = 1;
2605 cryst_lot[i] = site_lot[k][l];
2606 if (cryst_lot[i] < 0)
2612 cryst -> at_by_object[i] = 1;
2620 g_free (all_origin);
2621 g_free (from_origin);
2627 for (j=0; j<cryst ->
objects; j++)
2629 i += cryst -> at_by_object[j] * cryst -> pos_by_object[j];
2639 for (j=0; j<cryst ->
objects; j++)
2641 if (cryst_lot[j] < 0)
2643 k = - cryst_lot[j] - 1;
2645 for (l=0; l<c_obj ->
atoms; l++)
2647 m = c_obj -> at_list[l].sp;
2648 n = c_obj -> old_z[m];
2672 for (j=0; j<120; j++)
2676 tmp_nsps[i] = spec_num[j];
2688 for (j=0; j<120; j++)
2705 add_reader_info (_(
"The crystal will be created however some objects might be missing,\n"
2706 "Occupancy is too low compared to the number of site(s) per cell.\n\n"
2707 "<b>To build a crystal matching the defined occupancy</b>:\n"
2708 "\t <b>1)</b> If you are trying to read a CIF file, use the crystal builder instead.\n"
2709 "\t <b>2)</b> Modify the occupancy set-up to 'Completely random'.\n"
2710 "\t <b>3)</b> Increase the number of unit cells up to get rid of this message.\n\n"), 1);
2714 add_reader_info (_(
"Object(s) at equivalent positions have been removed\n"
2715 "to ensure the consistency of the model\n"
2716 "when using <b>P</b>eriodic <b>B</b>oundary <b>C</b>onditions\n "), 1);
2724 g_debug (
"CIF:: Impossible to retrieve atomic coordinates !");
2753 for (j=0; j<
CFKEYS-1; j++)
2784 cif_occup =
cif_get_value (
linekeys[lid], _(
"occupancy"), 0, linec, NULL, FALSE, FALSE, TRUE, FALSE, NULL);
2800 str = g_strdup_printf (_(
"It seems the CIF file contains <b>%d</b> distinct configurations\n"),
this_reader -> steps);
2805 str = g_strdup_printf (_(
"Impossible to use symmetry positions with multiple configurations\n"));
2813 cif_site =
cif_get_value (
linekeys[lid],
"disorder_group", 0, linec, NULL, FALSE, FALSE, TRUE, FALSE, NULL);
2814 if (cif_occup ==
this_reader -> steps && cif_occup == cif_site)
2816 add_reader_info (_(
"This CIF file could be describing a trajectory or a chemical reaction.\n"), 1);
2827 cif_action =
iask (_(
"Please select how to process the data in the CIF file"), _(
"Select how to process data"), 4,
atomes_main_window);
2831 add_reader_info (_(
"This CIF file could be describing a trajectory.\n"), 1);
2832 cif_action =
iask (_(
"Please select how to process the data in the CIF file"), _(
"Select how to process data"), 4,
atomes_main_window);
2843 str = g_strdup_printf (_(
"Select the configuration <i>c</i>, <i>c</i> ∈ [1-%d]"),
this_reader -> steps);
2848 if (cif_step < 1 || cif_step >
this_reader -> steps) cif_step = 0;
2857 str = g_strdup_printf (_(
"Working on configuration N°%d\n"), cif_step);
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
Function declarations for the mode edition window.
GtkTreeModel * replace_combo_tree(gboolean insert, int proj)
replace combo box in the tree view
int get_selected_object_id(gboolean visible, int p, gchar *str, atom_search *asearch)
get the id of the object selected (in contextual menu, or in combo box)
void to_insert_in_project(int stat, int orig, project *this_proj, atom_search *asearch, gboolean visible)
to insert object in project
atomic_object * get_atomic_object_by_origin(atomic_object *first, int oid, int aid)
get insert object from a list by id
atomic_object * cif_object
Binding to the Fortran90 subroutines.
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
double get_val_from_wyckoff(gchar *pos, gchar *wval)
get point value from wyckoff position
int occupancy(double occ, int cif_occ)
handle occupancy integer rouding
crystal_data * allocate_crystal_data(int objects, int species)
allocate crystal data pointer
int test_lattice(builder_edition *cbuilder, cell_info *cif_cell)
test lattice parameters
double get_value_from_pos(gchar *pos)
get position double value from string description
int read_space_group(builder_edition *cbuilder, int spg)
read space group N°spg data from file
Function declarations for the crystal builder.
void allocatoms(project *this_proj)
allocate project data
gchar * replace_markup(char *init, char *key, char *rep)
replace pattern in string
int * duplicate_int(int num, int *old_val)
copy a list of int
int ** allocdint(int xal, int yal)
allocate an int ** pointer
double * duplicate_double(int num, double *old_val)
copy a list of double
GtkWidget * atomes_main_window
gboolean * allocbool(int val)
allocate a gboolean * pointer
double ** allocddouble(int xal, int yal)
allocate a double ** pointer
double * allocdouble(int val)
allocate a double * pointer
int * allocint(int val)
allocate an int * pointer
gboolean cif_use_symmetry_positions
double string_to_double(gpointer string)
convert string to double
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
void combo_set_markup(GtkWidget *combo)
use pango markup in combo widget
element_data periodic_table_info[]
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
int iask(char *question, char *lab, int id, GtkWidget *win)
enter an integer value - prepare the dialog
Messaging function declarations.
integer(kind=c_int) function lattice(totl, lid, vectors, vmod, angles, lat, cfrac, apbc)
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void check_for_species(double v, int ato)
Fill the species for each atom and the associated data.
gchar * get_atom_disorder(gchar *line, int lid)
read atom disorder group from CIF file
gboolean cif_get_atomic_coordinates(int linec, int conf)
void file_get_to_line(int line_id)
reach line in CIF file
gchar * get_string_from_origin(space_group *spg)
get the space group origin from its name
int cif_file_get_number_of_positions(int lid)
get the number of symmetry positions
G_MODULE_EXPORT void set_cif_to_insert(GtkComboBox *box, gpointer data)
change the object to insert at an empty cif position
int cif_get_space_group(int linec, int conf)
get the space group from the CIF file
double get_z_from_periodic_table(gchar *lab)
get Z from atom label
gboolean cif_file_get_atoms_data(int conf, int lin, int cid[9])
void compute_lattice_properties(cell_info *cell, int box_id)
compute lattice parameters following cell description
gchar * cartkeys[CFKEYS][3]
void check_for_to_lab(int ato, gchar *stlab)
check atom label
int get_atom_wyckoff(gchar *line, int wid)
read Wyckoff position from CIF file
gchar * frackeys[CFKEYS-1][3]
space_group * duplicate_space_group(space_group *spg)
duplicate space ground information
int group_info_from_hm_key(int spg, gchar *key_hm)
get the space group information using the HM key from the CIF file
gboolean cif_get_symmetry_positions(int linec, int conf)
read the symmetry positions from the CIF file
gboolean cif_get_cell_data(int linec, int conf)
get the cell data from the CIF file
int read_space_group(builder_edition *cbuilder, int spg)
read space group N°spg data from file
int cif_file_get_data_in_loop(int linec, int lid)
get the number of "_" motifs in a line
void get_wyck_char(float val, int ax, int bx)
convert wyckoff value to string
int get_loop_line_id(int lid)
reach a line in the CIF file
float get_atom_coord(gchar *line, int mid)
read atom coordinates from CIF file
int cif_file_get_number_of_atoms(int linec, int lid, int nelem)
get the number of atom(s) in a CIF file
int cif_get_value(gchar *kroot, gchar *keyw, int lstart, int lend, gchar **cif_word, gboolean rec_val, gboolean all_ligne, gboolean total_num, gboolean record_position, int *line_position)
read pattern in CIF file
gboolean get_missing_object_from_user()
get missing atomic number in CIF file from the user
int get_setting_from_hm(gchar *hmk, int end)
Getting the space group parameters using the HM Key.
int get_loop_line_for_key(int linec, int conf, gchar *key_a, gchar *key_b)
search a string
void get_origin(space_group *spg)
get space group origin matrices
int open_cif_file(int linec)
open CIF file
gchar * cif_coord_opts[40][2]
gchar * get_atom_label(gchar *line, int lid)
read atom label from CIF file
int get_atom_id_from_periodic_table(atom_search *asearch)
get atom Z from selection in the periodic table
gchar * cif_retrieve_value(int linec, int conf, gchar *key_a, gchar *key_b, gboolean all_ligne, gboolean in_loop, gboolean warning)
retrieve a field value as string in the CIF file
int open_cif_configuration(int linec, int conf)
int test_lattice(builder_edition *cbuilder, cell_info *cif_cell)
test lattice parameters
int get_space_group_from_hm(gchar *hmk)
retrieve space group using the HM Key
void sort(int dim, int *tab)
sort, nim to max, a table by integer value
gchar * get_cif_word(gchar *mot)
get string from CIF file, EOL can be ugly
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
void add_reader_info(gchar *info, int mid)
append information message to the reader information
Functions declaration to read atomic coordinates.