symaux.red 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. module symaux; % Data for symmetry package.
  2. % Author: Karin Gatermann <Gatermann@sc.ZIB-Berlin.de>.
  3. CREATE!-PACKAGE('(symaux
  4. symatvec
  5. symcheck
  6. symchrep
  7. symhandl
  8. sympatch
  9. symwork),
  10. '(contrib symmetry));
  11. load!-package 'matrix;
  12. algebraic(operator @);
  13. algebraic( infix @);
  14. algebraic( precedence @,*);
  15. symbolic procedure give!_groups (u);
  16. % prints the elements of the abstract group
  17. begin
  18. return mk!+outer!+list(get!*available!*groups());
  19. end;
  20. put('availablegroups,'psopfn,'give!_groups);
  21. symbolic procedure print!_group (groupname);
  22. % prints the elements of the abstract group
  23. begin
  24. scalar g;
  25. if length(groupname)>1 then rederr("too many arguments");
  26. if length(groupname)<1 then rederr("group as argument missing");
  27. g:=reval car groupname;
  28. if available!*p(g) then
  29. return alg!:print!:group(g);
  30. end;
  31. put('printgroup,'psopfn,'print!_group);
  32. symbolic procedure print!_generators (groupname);
  33. % prints the generating elements of the abstract group
  34. begin
  35. scalar g;
  36. if length(groupname)>1 then rederr("too many arguments");
  37. if length(groupname)<1 then rederr("group as argument missing");
  38. g:=reval car groupname;
  39. if available!*p(g) then
  40. return alg!:generators(g);
  41. end;
  42. put('generators,'psopfn,'print!_generators);
  43. symbolic procedure character!_table (groupname);
  44. % prints the characters of the group
  45. begin
  46. scalar g;
  47. if length(groupname)>1 then rederr("too many arguments");
  48. g:=reval car groupname;
  49. if available!*p(g) then
  50. return alg!:characters(g);
  51. end;
  52. put('charactertable,'psopfn,'character!_table);
  53. symbolic procedure character!_nr (groupname);
  54. % prints the characters of the group
  55. begin
  56. scalar group,nr,char1;
  57. if length(groupname)>2 then rederr("too many arguments");
  58. if length(groupname)<2 then rederr("group or number missing");
  59. group:=reval car groupname;
  60. nr:=reval cadr groupname;
  61. if not(available!*p(group)) then
  62. rederr("no information upon group available");
  63. if not(irr!:nr!:p(nr,group)) then
  64. rederr("no character with this number");
  65. if !*complex then
  66. char1:=get!*complex!*character(group,nr) else
  67. char1:=get!*real!*character(group,nr);
  68. return alg!:print!:character(char1);
  69. end;
  70. put('characternr,'psopfn,'character!_nr);
  71. symbolic procedure irreducible!_rep!_table (groupname);
  72. % prints the irreducible representations of the group
  73. begin
  74. scalar g;
  75. if length(groupname)>1 then rederr("too many arguments");
  76. if length(groupname)<1 then rederr("group missing");
  77. g:=reval car groupname;
  78. if available!*p(g) then
  79. return alg!:irr!:reps(g);
  80. end;
  81. put('irreduciblereptable,'psopfn,'irreducible!_rep!_table);
  82. symbolic procedure irreducible!_rep!_nr (groupname);
  83. % prints the irreducible representations of the group
  84. begin
  85. scalar g,nr;
  86. if length(groupname)>2 then rederr("too many arguments");
  87. if length(groupname)<2 then rederr("group or number missing");
  88. g:=reval car groupname;
  89. if not(available!*p(g)) then
  90. rederr("no information upon group available");
  91. nr:=reval cadr groupname;
  92. if not(irr!:nr!:p(nr,g)) then
  93. rederr("no irreducible representation with this number");
  94. if !*complex then
  95. return
  96. alg!:print!:rep(get!*complex!*irreducible!*rep(g,nr))
  97. else return
  98. alg!:print!:rep(get!*real!*irreducible!*rep(g,nr));
  99. end;
  100. put('irreduciblerepnr,'psopfn,'irreducible!_rep!_nr);
  101. symbolic procedure canonical!_decomposition(representation);
  102. % computes the canonical decomposition of the given representation
  103. begin
  104. scalar repr;
  105. if length(representation)>1 then rederr("too many arguments");
  106. repr:=reval car representation;
  107. if representation!:p(repr) then
  108. return alg!:can!:decomp(mk!_internal(repr));
  109. end;
  110. put('canonicaldecomposition,'psopfn,'canonical!_decomposition);
  111. symbolic procedure sym!_character(representation);
  112. % computes the character of the given representation
  113. begin
  114. scalar repr;
  115. if length(representation)>1 then rederr("too many arguments");
  116. if length(representation)<1 then
  117. rederr("representation list missing");
  118. repr:=reval car representation;
  119. if representation!:p(repr) then
  120. return alg!:print!:character(mk!_character(mk!_internal(repr))) else
  121. rederr("that's no representation");
  122. end;
  123. put('character,'psopfn,'sym!_character);
  124. symbolic procedure symmetry!_adapted!_basis (arg);
  125. % computes the first part of the symmetry adapted bases of
  126. % the nr-th component
  127. % arg = (representation,nr)
  128. begin
  129. scalar repr,nr,res;
  130. if length(arg)>2 then rederr("too many arguments");
  131. if length(arg)<2 then rederr("group or number missing");
  132. repr:=reval car arg;
  133. nr:=reval cadr arg;
  134. if representation!:p(repr) then
  135. repr:=mk!_internal(repr) else
  136. rederr("that's no representation");
  137. if irr!:nr!:p(nr,get!_group!_in(repr)) then
  138. <<
  139. if not(null(mk!_multiplicity(repr,nr))) then
  140. res:= mk!+outer!+mat(mk!_part!_sym!_all(repr,nr))
  141. else
  142. res:=nil;
  143. >> else
  144. rederr("wrong number of an irreducible representation");
  145. return res;
  146. end;
  147. put('symmetrybasis,'psopfn,'symmetry!_adapted!_basis);
  148. symbolic procedure symmetry!_adapted!_basis!_part (arg);
  149. % computes the first part of the symmetry adapted bases
  150. % of the nr-th component
  151. % arg = (representation,nr)
  152. begin
  153. scalar repr,nr,res;
  154. if length(arg)>2 then rederr("too many arguments");
  155. if length(arg)<2 then rederr("group or number missing");
  156. repr:=reval car arg;
  157. nr:=reval cadr arg;
  158. if representation!:p(repr) then
  159. repr:=mk!_internal(repr) else
  160. rederr("that's no representation");
  161. if irr!:nr!:p(nr,get!_group!_in(repr)) then
  162. <<
  163. if not(null(mk!_multiplicity(repr,nr))) then
  164. res:= mk!+outer!+mat(mk!_part!_sym1(repr,nr))
  165. else
  166. res:=nil;
  167. >> else
  168. rederr("wrong number of an irreducible representation");
  169. return res;
  170. end;
  171. put('symmetrybasispart,'psopfn,'symmetry!_adapted!_basis!_part);
  172. symbolic procedure symmetry!_bases (representation);
  173. % computes the complete symmetry adapted basis
  174. begin
  175. scalar repr,res;
  176. if length(representation)>1 then rederr("too many arguments");
  177. if length(representation)<1 then rederr("representation missing");
  178. repr:=reval car representation;
  179. if representation!:p(repr) then
  180. <<
  181. res:= mk!+outer!+mat(mk!_sym!_basis(mk!_internal(repr)));
  182. >> else
  183. rederr("that's no representation");
  184. return res;
  185. end;
  186. put('allsymmetrybases,'psopfn,'symmetry!_bases);
  187. symbolic procedure sym!_diagonalize (arg);
  188. % diagonalizes a matrix with respect to a given representation
  189. begin
  190. scalar repr,matrix1;
  191. if (length(arg)>2) then rederr("too many arguments");
  192. if (length(arg)<2) then rederr("representation or matrix missing");
  193. repr:=reval cadr arg;
  194. matrix1:=reval (car arg);
  195. if alg!+matrix!+p(matrix1) then
  196. matrix1:=mk!+inner!+mat(matrix1)
  197. else
  198. rederr("first argument must be a matrix");
  199. if representation!:p(repr) then
  200. repr:=mk!_internal(repr) else
  201. rederr("that's no representation");
  202. if symmetry!:p(matrix1,repr) then
  203. return mk!+outer!+mat(mk!_diagonal(
  204. matrix1,repr)) else
  205. rederr("matrix has not the symmetry of this representation");
  206. end;
  207. put('diagonalize,'psopfn,'sym!_diagonalize);
  208. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  209. %
  210. % function to add new groups to the database by the user
  211. %
  212. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  213. symbolic procedure set!_generators!_group (arg);
  214. % a group is generated by some elements
  215. begin
  216. scalar group, generators,relations,rel;
  217. if length(arg)>3 then rederr("too many arguments");
  218. if length(arg)<2 then
  219. rederr("group identifier or generator list missing");
  220. group:=reval car arg;
  221. generators:=reval cadr arg;
  222. if length(arg)=3 then
  223. relations:=reval caddr arg else
  224. relations:=nil;
  225. if not(idp(group)) then
  226. rederr("first argument must be a group identifier");
  227. generators:=mk!+inner!+list(generators);
  228. if not(identifier!:list!:p(generators)) then
  229. rederr("second argument must be a list of generator identifiers")
  230. else set!*generators(group,generators);
  231. relations:=mk!_relation!_list(relations);
  232. for each rel in relations do
  233. if not(relation!:list!:p(group,rel)) then
  234. rederr("equations in generators are demanded");
  235. set!*relations(group,relations);
  236. writepri("setgenerators finished",'only);
  237. end;
  238. put('setgenerators,'psopfn,'set!_generators!_group);
  239. symbolic procedure set!_elements(arg);
  240. % each element<>id of a group has a representation
  241. % as product of generators
  242. % the identity is called id
  243. begin
  244. scalar elemreps,replist,elems,group;
  245. if length(arg)>2 then rederr("too many arguments");
  246. if length(arg)<2 then
  247. rederr("missing group or list with group elements with generators ");
  248. group:=reval car arg;
  249. if not(idp(group)) then
  250. rederr("first argument must be a group identifier");
  251. elemreps:=reval cadr arg;
  252. elemreps:=mk!_relation!_list(elemreps);
  253. for each replist in elemreps do
  254. if not(generator!:list!:p(group,cadr replist)) then
  255. rederr("group elements should be represented in generators");
  256. for each replist in elemreps do
  257. if not((length(car replist)=1) and idp(caar replist)) then
  258. rederr("first must be one group element");
  259. elems:= for each replist in elemreps collect caar replist;
  260. elems:=append(list('id),elems);
  261. set!*elems!*group(group,elems);
  262. set!*elemasgen(group,elemreps);
  263. writepri("setelements finished",'only);
  264. end;
  265. put('setelements,'psopfn,'set!_elements);
  266. symbolic procedure set!_group!_table (arg);
  267. % a group table gives the result of the product of two elements
  268. begin
  269. scalar table,group,z,s;
  270. if length(arg)>2 then rederr("too many arguments");
  271. if length(arg)<2 then
  272. rederr("missing group or group table as a matrix ");
  273. group:=reval car arg;
  274. if not(idp(group)) then
  275. rederr("first argument must be a group identifier");
  276. table:=reval cadr arg;
  277. if alg!+matrix!+p(table) then
  278. table:=mk!+inner!+mat(table);
  279. table:=for each z in table collect
  280. for each s in z collect prepsq(s);
  281. if group!:table!:p(group,table) then
  282. <<
  283. set!*grouptable(group,table);
  284. set!*inverse(group,mk!*inverse!*list(table));
  285. set!*group(group,mk!*equiclasses(table));
  286. set!*storing(group);
  287. >> else rederr("table is not a group table");
  288. writepri("setgrouptable finished",'only);
  289. end;
  290. put('setgrouptable,'psopfn,'set!_group!_table);
  291. symbolic procedure set!_real!_rep(arg);
  292. % store the real irreducible representations
  293. begin
  294. scalar replist,type;
  295. if length(arg)>2 then rederr("too many arguments");
  296. if length(arg)<2 then
  297. rederr("representation or type missing");
  298. replist:=reval car arg;
  299. type:=reval cadr arg;
  300. if (not(type= 'realtype) and not(type = 'complextype)) then
  301. rederr("only real or complex types possible");
  302. if get!*order(get!_group!_out(replist))=0 then
  303. rederr("elements of the groups must be set first");
  304. if representation!:p(replist) then
  305. replist:=(mk!_internal(replist));
  306. set!*representation(get!_group!_in(replist),
  307. append(list(type),cdr replist),'real);
  308. writepri("Rsetrepresentation finished",'only);
  309. end;
  310. put('Rsetrepresentation,'psopfn,'set!_real!_rep);
  311. symbolic procedure set!_complex!_rep(arg);
  312. % store the complex irreducible representations
  313. begin
  314. scalar replist;
  315. if length(arg)>1 then rederr("too many arguments");
  316. if length(arg)<1 then
  317. rederr("representation missing");
  318. replist:=reval car arg;
  319. if get!*order(get!_group!_out(replist))=0 then
  320. rederr("elements of the groups must be set first");
  321. if representation!:p(replist) then
  322. replist:=(mk!_internal(replist));
  323. set!*representation(get!_group!_in(replist),cdr replist,'complex);
  324. writepri("Csetrepresentation finished",'only);
  325. end;
  326. put('Csetrepresentation,'psopfn,'set!_complex!_rep);
  327. symbolic procedure mk!_available(arg);
  328. % group is only then made available, if all information was given
  329. begin
  330. scalar group;
  331. if length(arg)>1 then rederr("too many arguments");
  332. if length(arg)<1 then
  333. rederr("group identifier missing");
  334. group:=reval car arg;
  335. if check!:complete!:rep!:p(group) then
  336. set!*available(group);
  337. writepri("setavailable finished",'only);
  338. end;
  339. put('setavailable,'psopfn,'mk!_available);
  340. symbolic procedure update!_new!_group (arg);
  341. % stores the user defined new abstract group in a file
  342. begin
  343. scalar group;
  344. if length(arg)>2 then rederr("too many arguments");
  345. if length(arg)<2 then
  346. rederr("group or filename missing");
  347. group:=reval car arg;
  348. if available!*p(group) then write!:to!:file(group,reval cadr arg);
  349. writepri("storegroup finished",'only);
  350. end;
  351. put('storegroup,'psopfn,'update!_new!_group);
  352. procedure loadgroups(fname);
  353. % loads abstract groups from a file which was created from a user
  354. % by newgroup and updategroup
  355. begin
  356. in fname;
  357. write"group loaded";
  358. end;
  359. endmodule;
  360. end;