Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate type of MSG #267

Merged
merged 6 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/python-spglib.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,9 @@ Arguments
- `mag_symprec`: See {ref}`py_get_magnetic_symmetry`
- `is_axial`: See {ref}`py_get_magnetic_symmetry`

Returned `dataset` is a dictionary.
If successful, returned `dataset` is a dictionary.
The description of its keys is given at {ref}`magnetic_spglib_dataset`.
If the magnetic symmetry search failed, `dataset` is `None`.

### `get_magnetic_spacegroup_type`

Expand Down
3 changes: 3 additions & 0 deletions src/magnetic_spacegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ static int get_reference_space_group(Spacegroup **ref_sg,
/* Determine type of MSG and generator of factor group of MSG over XSG */
type = get_magnetic_space_group_type(&representatives, magnetic_symmetry,
sym_fsg->size, sym_xsg->size);
if (type == 0) {
goto err;
}
debug_print("type=%d\n", type);
LecrisUT marked this conversation as resolved.
Show resolved Hide resolved

/* Choose reference setting */
Expand Down
4 changes: 3 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ For example, to run `test_symmetry_search.test_spg_get_symmetry`

```shell
# at build/test
./CTests --gtest_filter=test_spg_get_symmetry
./CTests --gtest_filter=test_symmetry_search.test_spg_get_symmetry
```

If you use debuggers like gdb or lldb, recompile with `CMAKE_BUILD_TYPE=Debug`.

## How to add a new test file

1. Create `<your_test_suite_name>.cpp`
Expand Down
61 changes: 61 additions & 0 deletions test/test_magnetic_symmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,67 @@ TEST(test_magnetic_symmetry, test_spg_get_symmetry_with_tensors_rough_symprec) {
free(time_reversals);
}

TEST(test_magnetic_symmetry, test_spgms_get_magnetic_dataset_high_mag_symprec) {
// https://github.com/spglib/spglib/issues/249
double lattice[3][3] = {
{0.00000000, -5.00000000, -2.50000000},
{0.00000000, 0.00000000, 4.33012702},
{-4.05000000, 0.00000000, 0.00000000},
};
double positions[][3] = {
{0.50000000, 0.33333333, 0.33333333},
{0.50000000, 0.66666667, 0.66666667},
{0.00000000, 0.00000000, 0.00000000},
{0.00000000, 0.00000000, 0.50000000},
{0.00000000, 0.50000000, 0.50000000},
{0.00000000, 0.50000000, 0.00000000},
};
int types[] = {1, 1, 1, 2, 2, 2};
double tensors[] = {
-0.00200000, 0.00200000, 1.90000000, 0.00200000, 0.00000000,
1.91100000, -0.00100000, 0.00200000, -2.23300000, -0.00000000,
-0.00000000, -0.06000000, 0.00000000, 0.00000000, -0.03200000,
0.00000000, -0.00000000, -0.02900000,
};
int num_atoms = 6;

int max_size = num_atoms * 96;

double symprec = 1e-5;
double mag_symprec = 1e-1; // with high mag_symprec

int i, size;
int equivalent_atoms[3];
double primitive_lattice[3][3];
int(*rotations)[3][3];
double(*translations)[3];
int *spin_flips;
int *time_reversals;

rotations = (int(*)[3][3])malloc(sizeof(int[3][3]) * max_size);
translations = (double(*)[3])malloc(sizeof(double[3]) * max_size);
spin_flips = (int *)malloc(sizeof(int *) * max_size);
time_reversals = (int *)malloc(sizeof(int *) * max_size);

size = spgms_get_symmetry_with_site_tensors(
rotations, translations, equivalent_atoms, primitive_lattice,
spin_flips, max_size, lattice, positions, types, tensors,
1 /* tensor_rank */, num_atoms, 1 /* with_time_reversal */,
1 /* is_axial */, symprec, -1 /* angle_tolerance */, mag_symprec);
ASSERT_TRUE(size > 0);

SpglibMagneticDataset *dataset;
dataset =
spgms_get_magnetic_dataset(lattice, positions, types, tensors, 1,
num_atoms, 1, symprec, -1, mag_symprec);
LecrisUT marked this conversation as resolved.
Show resolved Hide resolved

free(rotations);
free(translations);
free(spin_flips);
free(time_reversals);
if (dataset != NULL) spg_free_magnetic_dataset(dataset);
}

TEST(test_magnetic_symmetry, test_with_broken_symmetry) {
// https://github.com/spglib/spglib/issues/194
// Part of "mp-806965" in the Materials Project database
Expand Down