546 mixture_().writeStress(file);
552 if (command ==
"WRITE_W_BASIS") {
553 readEcho(in, filename);
554 w().writeBasis(filename);
556 if (command ==
"WRITE_W_RGRID") {
557 readEcho(in, filename);
558 w().writeRGrid(filename);
560 if (command ==
"WRITE_C_BASIS") {
561 readEcho(in, filename);
562 c().writeBasis(filename);
564 if (command ==
"WRITE_C_RGRID") {
565 readEcho(in, filename);
566 c().writeRGrid(filename);
568 if (command ==
"WRITE_BLOCK_C_RGRID") {
569 readEcho(in, filename);
570 mixture_().writeBlockCRGrid(filename);
572 if (command ==
"WRITE_Q_SLICE") {
573 int polymerId, blockId, directionId, segmentId;
574 readEcho(in, filename);
579 Log::file() <<
Str(
"polymer ID ", 21) << polymerId <<
"\n"
580 <<
Str(
"block ID ", 21) << blockId <<
"\n"
581 <<
Str(
"direction ID ", 21) << directionId
583 <<
Str(
"segment ID ", 21) << segmentId
585 mixture_().writeQSlice(filename, polymerId, blockId,
586 directionId, segmentId);
588 if (command ==
"WRITE_Q_TAIL") {
589 readEcho(in, filename);
590 int polymerId, blockId, directionId;
594 Log::file() <<
Str(
"polymer ID ", 21) << polymerId <<
"\n"
595 <<
Str(
"block ID ", 21) << blockId <<
"\n"
596 <<
Str(
"direction ID ", 21) << directionId
598 mixture_().writeQTail(filename, polymerId, blockId, directionId);
600 if (command ==
"WRITE_Q") {
601 readEcho(in, filename);
602 int polymerId, blockId, directionId;
606 Log::file() <<
Str(
"polymer ID ", 21) << polymerId <<
"\n"
607 <<
Str(
"block ID ", 21) << blockId <<
"\n"
608 <<
Str(
"direction ID ", 21) << directionId
610 mixture_().writeQ(filename, polymerId, blockId, directionId);
612 if (command ==
"WRITE_Q_ALL") {
613 readEcho(in, filename);
614 mixture_().writeQAll(filename);
616 if (command ==
"WRITE_STARS") {
617 readEcho(in, filename);
618 domain_().writeStars(filename);
620 if (command ==
"WRITE_WAVES") {
621 readEcho(in, filename);
622 domain_().writeWaves(filename);
624 if (command ==
"WRITE_GROUP") {
625 readEcho(in, filename);
626 domain_().writeGroup(filename);
628 if (command ==
"BASIS_TO_RGRID") {
629 readEcho(in, inFileName);
630 readEcho(in, outFileName);
631 fieldIo.convertBasisToRGrid(inFileName, outFileName);
633 if (command ==
"RGRID_TO_BASIS") {
634 readEcho(in, inFileName);
635 readEcho(in, outFileName);
636 fieldIo.convertRGridToBasis(inFileName, outFileName);
638 if (command ==
"KGRID_TO_RGRID") {
639 readEcho(in, inFileName);
640 readEcho(in, outFileName);
641 fieldIo.convertKGridToRGrid(inFileName, outFileName);
643 if (command ==
"RGRID_TO_KGRID") {
644 readEcho(in, inFileName);
645 readEcho(in, outFileName);
646 fieldIo.convertRGridToKGrid(inFileName, outFileName);
648 if (command ==
"BASIS_TO_KGRID") {
649 readEcho(in, inFileName);
650 readEcho(in, outFileName);
651 fieldIo.convertBasisToKGrid(inFileName, outFileName);
653 if (command ==
"KGRID_TO_BASIS") {
654 readEcho(in, inFileName);
655 readEcho(in, outFileName);
656 fieldIo.convertKGridToBasis(inFileName, outFileName);
658 if (command ==
"CHECK_RGRID_SYMMETRY") {
660 readEcho(in, inFileName);
661 readEcho(in, epsilon);
663 hasSymmetry = fieldIo.hasSymmetry(inFileName, epsilon);
666 <<
"Symmetry of r-grid file matches this space group"
667 << std::endl << std::endl;
670 <<
"Symmetry of r-grid file does not match this\n"
671 <<
"space group to within error threshold of "
672 <<
Dbl(epsilon) <<
" ." << std::endl << std::endl;
675 if (command ==
"COMPARE_BASIS") {
676 std::string filecompare1, filecompare2;
677 readEcho(in, filecompare1);
678 readEcho(in, filecompare2);
679 fieldIo.compareFieldsBasis(filecompare1, filecompare2);
681 if (command ==
"COMPARE_RGRID") {
682 std::string filecompare1, filecompare2;
683 readEcho(in, filecompare1);
684 readEcho(in, filecompare2);
685 fieldIo.compareFieldsRGrid(filecompare1, filecompare2);
687 if (command ==
"SCALE_BASIS") {
689 readEcho(in, inFileName);
690 readEcho(in, outFileName);
691 readEcho(in, factor);
692 fieldIo.scaleFieldsBasis(inFileName, outFileName, factor);
694 if (command ==
"SCALE_RGRID") {
696 readEcho(in, inFileName);
697 readEcho(in, outFileName);
698 readEcho(in, factor);
699 fieldIo.scaleFieldsRGrid(inFileName, outFileName, factor);
701 if (command ==
"EXPAND_RGRID_DIMENSION") {
702 readEcho(in, inFileName);
703 readEcho(in, outFileName);
709 Log::file() <<
Str(
"Expand dimension to: ") << d <<
"\n";
714 for (
int i = 0; i < d-D; i++) {
715 in >> newGridDimensions[i];
718 <<
Str(
"Numbers of grid points in added dimensions : ");
719 for (
int i = 0; i < d-D; i++) {
720 Log::file() << newGridDimensions[i] <<
" ";
724 fieldIo.expandRGridDimension(inFileName, outFileName,
725 d, newGridDimensions);
728 if (command ==
"REPLICATE_UNIT_CELL") {
729 readEcho(in, inFileName);
730 readEcho(in, outFileName);
734 for (
int i = 0; i < D; i++){
737 for (
int i = 0; i < D; i++){
738 Log::file() <<
"Replicate unit cell in direction "
743 fieldIo.replicateUnitCell(inFileName, outFileName, replicas);
746 if (command ==
"ESTIMATE_W_BASIS") {
747 readEcho(in, inFileName);
748 readEcho(in, outFileName);
749 fieldIo.estimateWBasis(inFileName, outFileName,
750 interaction().chi());
752 if (command ==
"READ_H_BASIS") {
753 readEcho(in, filename);
754 h().readBasis(filename);
757 if (command ==
"READ_H_RGRID") {
758 readEcho(in, filename);
759 h().readRGrid(filename);
762 if (command ==
"WRITE_H_BASIS") {
763 readEcho(in, filename);
764 h().writeBasis(filename);
766 if (command ==
"WRITE_H_RGRID") {
767 readEcho(in, filename);
768 h().writeRGrid(filename);
770 if (command ==
"READ_MASK_BASIS") {
771 readEcho(in, filename);
772 mask().readBasis(filename);
774 if (command ==
"READ_MASK_RGRID") {
775 readEcho(in, filename);
776 mask().readRGrid(filename);
778 if (command ==
"WRITE_MASK_BASIS") {
779 readEcho(in, filename);
780 mask().writeBasis(filename);
782 if (command ==
"WRITE_MASK_RGRID") {
783 readEcho(in, filename);
784 mask().writeRGrid(filename);
786 if (command ==
"WRITE_TIMERS") {
787 readEcho(in, filename);
789 fileMaster().openOutputFile(filename, file);
793 if (command ==
"CLEAR_TIMERS") {
797 << command << std::endl;
806 template <
int D,
class T>
820 template <
int D,
class T>
838 mixture_().compute(
w().rgrid(), c_().rgrid(),
mask().phiTot());
839 mixture_().setIsSymmetric(
w().isSymmetric());
840 c_().setHasData(
true);
844 if (
w().isSymmetric()) {
846 domain_().fieldIo().convertRGridToBasis(
c().rgrid(), c_().basis(),
848 c_().setIsSymmetric(
true);
860 template <
int D,
class T>
864 if (!mixture_().hasStress()) {
865 mixture_().computeStress(
mask().phiTot());
880 template <
int D,
class T>
903 int error =
iterator().solve(isContinuation);
911 if (!mixture_().hasStress()) {
927 template <
int D,
class T>
949 template <
int D,
class T>
962 template <
int D,
class T>
965 c_().setHasData(
false);
974 template <
int D,
class T>
979 UTIL_CHECK(domain_().lattice() == unitCell.lattice());
982 domain_().unitCell() = unitCell;
985 if (domain_().hasGroup() && !domain_().basis().isInitialized()) {
986 domain_().makeBasis();
990 UTIL_CHECK(domain_().unitCell().isInitialized());
991 UTIL_CHECK(domain_().unitCell().lattice() == domain_().lattice());
992 if (domain_().hasGroup()) {
993 UTIL_CHECK(domain_().basis().isInitialized());
1002 template <
int D,
class T>
1010 domain_().unitCell().set(domain_().lattice(), parameters);
1012 domain_().unitCell().setParameters(parameters);
1016 if (domain_().hasGroup() && !domain_().basis().isInitialized()) {
1017 domain_().makeBasis();
1021 UTIL_CHECK(domain_().unitCell().isInitialized());
1022 UTIL_CHECK(domain_().unitCell().lattice() == domain_().lattice());
1023 if (domain_().hasGroup()) {
1024 UTIL_CHECK(domain_().basis().isInitialized());
1033 template <
int D,
class T>
1037 mixture_().clearUnitCellData();
1038 domain_().waveList().clearUnitCellData();
1049 template <
int D,
class T>
1052 out <<
"System{" << std::endl;
1055 domain().writeParam(out);
1062 out <<
"}" << std::endl;
1070 template <
int D,
class T>
1086 template <
int D,
class T>
1102 template <
int D,
class T>
1103 void System<D,T>::allocateFieldsGrid()
1107 int nMonomer = mixture_().nMonomer();
1113 IntVec<D> const & dimensions = domain_().mesh().dimensions();
1116 w().setNMonomer(nMonomer);
1117 w().allocateRGrid(dimensions);
1120 c_().setNMonomer(nMonomer);
1121 c_().allocateRGrid(dimensions);
1124 h().setNMonomer(nMonomer);
1127 if (hasEnvironment()) {
1128 if (environment().generatesMask()) {
1129 mask().allocateRGrid(dimensions);
1131 if (environment().generatesExternalFields()) {
1132 h().allocateRGrid(dimensions);
1136 isAllocatedGrid_ =
true;
1142 template <
int D,
class T>
1143 void System<D,T>::allocateFieldsBasis()
1147 const int nMonomer = mixture_().nMonomer();
1151 UTIL_CHECK(domain_().basis().isInitialized());
1152 const int nBasis = domain_().basis().nBasis();
1158 w().allocateBasis(nBasis);
1159 c_().allocateBasis(nBasis);
1162 if (hasEnvironment()) {
1163 if (environment().generatesMask()) {
1164 mask().allocateBasis(nBasis);
1166 if (environment().generatesExternalFields()) {
1167 h().allocateBasis(nBasis);
1171 isAllocatedBasis_ =
true;
1177 template <
int D,
class T>
1178 void System<D,T>::readEcho(std::istream& in, std::string&
string)
const
1182 UTIL_THROW(
"Unable to read a string parameter.");
1190 template <
int D,
class T>
1191 void System<D,T>::readEcho(std::istream& in,
double& value)
const
1195 UTIL_THROW(
"Unable to read floating point parameter.");