3
$\begingroup$

Following the tutorial on Exploring Symmetries of Crystal Systems and using the code below:

Clear["Global`*"]; symmetryprops = {"Entity", 
  "RequiredPointGroupSymmetries", "CrystallographicPointGroups", 
  "CrystallographicSpaceGroups", "BravaisLattices", "LatticeSystems"};

symmetryheader = 
  StringReplace[
   Prepend[CommonName[
     EntityProperty["CrystalFamily", #] & /@ Rest[symmetryprops]], 
    CommonName[Entity["CrystalSystem"]]], "crystallographic" -> ""];

TextGrid[
 Prepend[MapAt[Length, 
   EntityValue["CrystalSystem", symmetryprops], {All, 3 ;; 5}], 
  symmetryheader], 
 Sequence[Dividers -> All, 
  Background -> {Automatic, {{LightBlue, None}}}]]

Mathematica gives me warning messages:

Error: CommonName:Entity[CrystalSystem] is not an entity. StringReplace:Stringorlistofstringsexpectedatposition1inStringReplace[{CommonName[Entity[CrystalSystem]],requiredpointgroupsymmetry,crystallographicpointgroups,crystallographicspacegroups,Bravaislattice,latticesystems},crystallographic]

Why?

$\endgroup$
1
  • $\begingroup$ The error message seems pretty clear here, the thing you are passing to StringReplace is not a string. $\endgroup$
    – Jason B.
    Nov 17, 2023 at 13:46

1 Answer 1

4
$\begingroup$

CommonName must be mapped over x

Replace CommonName[Entity[CrystalSystem]] with CrystalSystem

Clear["Global`*"]; 

symmetryprops = {"Entity", 
  "RequiredPointGroupSymmetries", "CrystallographicPointGroups", 
  "CrystallographicSpaceGroups", "BravaisLattices", "LatticeSystems"};

x = EntityProperty["CrystalFamily", #] & /@ Rest[symmetryprops];

symmetryheader =
 StringReplace[Prepend[CommonName /@ x, "CrystalSystem"], 
  "crystallographic" -> ""]

TextGrid[
 Prepend[MapAt[Length, 
   EntityValue["CrystalSystem", symmetryprops], {All, 3 ;; 5}], 
  symmetryheader], 
 Sequence[Dividers -> All, 
  Background -> {Automatic, {{LightBlue, None}}}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.