PSCF v1.5.0
System.tpp
1#ifndef RP_SYSTEM_TPP
2#define RP_SYSTEM_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "System.h"
12
13#include <rp/fts/simulator/Simulator.h>
14#include <rp/fts/simulator/SimulatorFactory.h>
15#include <rp/fts/compressor/Compressor.h>
16#include <rp/fts/compressor/CompressorFactory.h>
17#include <rp/scft/sweep/Sweep.h>
18#include <rp/scft/sweep/SweepFactory.h>
19#include <rp/scft/iterator/Iterator.h>
20#include <rp/scft/iterator/IteratorFactory.h>
21#include <rp/scft/ScftThermo.h>
22#include <rp/environment/EnvironmentFactory.h>
23#include <rp/solvers/Mixture.h>
24#include <rp/solvers/MixtureModifier.h>
25#include <rp/field/Domain.h>
26#include <rp/field/FieldIo.h>
27#include <rp/field/Mask.h>
28#include <rp/field/WFields.h>
29#include <rp/field/CFields.h>
30#include <rp/environment/Environment.h>
31
32#include <pscf/field/WaveList.h>
33#include <pscf/field/FFT.h>
34#include <pscf/field/RField.h>
35#include <pscf/field/RFieldDft.h>
36#include <pscf/crystal/Basis.h>
37#include <pscf/crystal/UnitCell.h>
38
39#include <pscf/interaction/Interaction.h>
40#include <pscf/mesh/Mesh.h>
41#include <pscf/math/IntVec.h>
42
43#include <util/containers/DArray.h>
44#include <util/containers/FSArray.h>
45#include <util/param/BracketPolicy.h>
46#include <util/param/ParamComponent.h>
47#include <util/signal/Signal.h>
48#include <util/format/Str.h>
49#include <util/format/Int.h>
50#include <util/format/Dbl.h>
51#include <util/misc/ioUtil.h>
52#include <util/misc/FileMaster.h>
53
54#include <string>
55#include <unistd.h>
56
57namespace Pscf {
58namespace Rp {
59
60 using namespace Util;
61
62 namespace {
63
64 /*
65 * Stop if the arguments of a command could not be read (used in
66 * readCommands). Without this, the command would be executed with
67 * unset or old argument values.
68 */
69 inline
70 void checkCommandInput(std::istream& in, std::string const & command)
71 {
72 if (in.fail()) {
73 Log::file() << "\nError reading the arguments of command "
74 << command << std::endl;
75 UTIL_THROW("Error reading command arguments");
76 }
77 }
78
79 }
80
81 /*
82 * Constructor.
83 */
84 template <int D, class T>
86 : cPtr_(nullptr),
87 wPtr_(nullptr),
88 hPtr_(nullptr),
89 maskPtr_(nullptr),
90 mixturePtr_(nullptr),
91 mixtureModifierPtr_(nullptr),
92 domainPtr_(nullptr),
93 interactionPtr_(nullptr),
94 scftPtr_(nullptr),
95 environmentPtr_(nullptr),
96 environmentFactoryPtr_(nullptr),
97 iteratorPtr_(nullptr),
98 iteratorFactoryPtr_(nullptr),
99 sweepPtr_(nullptr),
100 sweepFactoryPtr_(nullptr),
101 simulatorPtr_(nullptr),
102 simulatorFactoryPtr_(nullptr),
103 fileMasterPtr_(nullptr),
104 tmpUnitCellPtr_(nullptr),
105 polymerModel_(PolymerModel::Thread),
106 isAllocatedGrid_(false),
107 isAllocatedBasis_(false),
108 hasMixture_(false)
109 {
110 setClassName("System"); // Set block label in parameter file
111 BracketPolicy::set(BracketPolicy::Optional);
112 T::init();
113
114 // Create field containers
115 cPtr_ = new CFields<D,T>();
116 wPtr_ = new WFields<D,T>();
117 hPtr_ = new WFields<D,T>();
118 maskPtr_ = new Mask<D,T>();
119
120 // Create non-optional components
121 mixturePtr_ = new Mixture<D,T>();
122 mixtureModifierPtr_ = new MixtureModifier<D,T>();
123 interactionPtr_ = new Interaction();
124 domainPtr_ = new Domain<D,T>();
125 fileMasterPtr_ = new FileMaster();
126 tmpUnitCellPtr_ = new UnitCell<D>();
127
128 // Create ScftThermo after all the components that its base class
129 // SystemConstRef refers to, including the FileMaster
130 scftPtr_ = new ScftThermo<D,T>(*this);
131
132 // Create Factories for optional components
133 environmentFactoryPtr_
134 = new EnvironmentFactory<D,T>(*this);
135 iteratorFactoryPtr_ = new IteratorFactory<D,T>(*this);
136 sweepFactoryPtr_ = new SweepFactory<D,T>(*this);
137 simulatorFactoryPtr_ = new SimulatorFactory<D,T>(*this);
138
139 // Create associations among child components
140 mixtureModifier().associate(mixture_());
141 domain_().setFileMaster(*fileMasterPtr_);
142 w().setFieldIo(domain_().fieldIo());
143 w().setReadUnitCell(domain_().unitCell());
144 w().setWriteUnitCell(domain_().unitCell());
145 h().setFieldIo(domain_().fieldIo());
146 h().setReadUnitCell(*tmpUnitCellPtr_);
147 h().setWriteUnitCell(domain_().unitCell());
148 mask().setFieldIo(domain_().fieldIo());
149 mask().setReadUnitCell(*tmpUnitCellPtr_);
150 mask().setWriteUnitCell(domain_().unitCell());
151 c_().setFieldIo(domain_().fieldIo());
152 c_().setWriteUnitCell(domain_().unitCell());
153
154 /*
155 * Reading unit cell parameters from field file headers:
156 * Note the arguments of setReadUnitCell functions used above:
157 * When w is read from a file in basis or r-grid format, the
158 * parameters of the system unit cell, domain_().unitCell(), are
159 * reset to those in the field file header. When imposed fields h()
160 * and mask() are read from a file, however, unit cell parameters
161 * from the field file header are instead read into a mutable
162 * workspace object, *tmpUnitCellPtr_, and are ignored.
163 */
164
165 /*
166 * Use of "signals" to maintain data relationships:
167 * Signals are instances of Unit::Signal<void> that are used to
168 * notify "observer" objects of modification of data owned by a
169 * related "notifier" object. Each signal is owned by a notifier
170 * object that maintains data that may be modified. Each signal
171 * maintains a list of observers objects that should be notified
172 * whenever the data owned by the notifier object changes. Each
173 * observer is added by the Signal<void>::addObserver function
174 * template, which takes two arguments: a reference to an observer
175 * object (i.e., an instance of a class) and a pointer to a member
176 * function of that class which will be invoked on that object when
177 * the signal is triggered by modification of associated data.
178 */
179
180 // Addition of observers to signals
181
182 // Signal triggered by unit cell modification
183 Signal<void>& cellSignal = domain_().unitCell().signal();
185
186 // Signal triggered by basis construction
187 Signal<void>& basisSignal = domain_().basis().signal();
188 basisSignal.addObserver(*this, &System<D,T>::allocateFieldsBasis);
189
190 // Signal triggered by w-field modification
191 w().signal().addObserver(*this, &System<D,T>::clearCFields);
192
193 // Signal triggered by h-field modification
194 h().signal().addObserver(*this, &System<D,T>::clearCFields);
195
196 // Signal triggered by mask modification
197 mask().signal().addObserver(*this, &System<D,T>::clearCFields);
198 }
199
200 /*
201 * Destructor.
202 */
203 template <int D, class T>
205 {
206 // Delete optional elements
207 if (environmentPtr_) {
208 delete environmentPtr_;
209 }
210 if (iteratorPtr_) {
211 delete iteratorPtr_;
212 }
213 if (sweepPtr_) {
214 delete sweepPtr_;
215 }
216 if (simulatorPtr_) {
217 delete simulatorPtr_;
218 }
219
220 // Delete factories
221 delete environmentFactoryPtr_;
222 delete iteratorFactoryPtr_;
223 delete sweepFactoryPtr_;
224 delete simulatorFactoryPtr_;
225
226 // Delete other non-optional components
227 delete mixturePtr_;
228 delete mixtureModifierPtr_;
229 delete interactionPtr_;
230 delete domainPtr_;
231 delete scftPtr_;
232 delete fileMasterPtr_;
233 delete tmpUnitCellPtr_;
234
235 // Delete field containers
236 delete maskPtr_;
237 delete hPtr_;
238 delete wPtr_;
239 delete cPtr_;
240 }
241
242 // Lifetime (called in main program)
243
244 /*
245 * Process command line options.
246 */
247 template <int D, class T>
248 void System<D,T>::setOptions(int argc, char **argv)
249 {
250 bool eFlag = false; // echo
251 bool dFlag = false; // spatial dimension (1, 2, or 3)
252 bool pFlag = false; // param file
253 bool cFlag = false; // command file
254 bool iFlag = false; // input prefix
255 bool oFlag = false; // output prefix
256 bool tFlag = false; // thread count
257 char* pArg = 0;
258 char* cArg = 0;
259 char* iArg = 0;
260 char* oArg = 0;
261 int dArg = 0;
262 int tArg = 0;
263
264 // Read program arguments
265 int c;
266 opterr = 0;
267 while ((c = getopt(argc, argv, "ed:p:c:i:o:t:")) != -1) {
268 switch (c) {
269 case 'e':
270 eFlag = true;
271 break;
272 case 'd':
273 dFlag = true;
274 dArg = atoi(optarg);
275 break;
276 case 'p': // parameter file
277 pFlag = true;
278 pArg = optarg;
279 break;
280 case 'c': // command file
281 cFlag = true;
282 cArg = optarg;
283 break;
284 case 'i': // input prefix
285 iFlag = true;
286 iArg = optarg;
287 break;
288 case 'o': // output prefix
289 oFlag = true;
290 oArg = optarg;
291 break;
292 case 't': // thread count, if set by user
293 tFlag = true;
294 tArg = atoi(optarg);
295 break;
296 case '?':
297 Log::file() << "Unknown option -" << optopt << std::endl;
298 UTIL_THROW("Invalid command line option");
299 }
300 }
301
302 // Process program arguments
303
304 // Check required option -d
305 if (dFlag) {
306 UTIL_CHECK(D == dArg);
307 } else {
308 UTIL_THROW("Missing required -d option");
309 }
310
311 // Check required option -p, set parameter file name
312 if (pFlag) {
313 fileMaster().setParamFileName(std::string(pArg));
314 } else {
315 UTIL_THROW("Missing required -p option - no parameter file");
316 }
317
318 // Check required option -c, set command file name
319 if (cFlag) {
320 fileMaster().setCommandFileName(std::string(cArg));
321 } else {
322 UTIL_THROW("Missing required -c option - no command file");
323 }
324
325 // If option -e, set to echo parameters as they are read
326 if (eFlag) {
328 }
329
330 // If option -i, set path prefix for input files
331 if (iFlag) {
332 fileMaster().setInputPrefix(std::string(iArg));
333 }
334
335 // If option -o, set path prefix for output files
336 if (oFlag) {
337 fileMaster().setOutputPrefix(std::string(oArg));
338 }
339
340 // If option -t, set the thread count
341 if (tFlag) {
342 if (tArg <= 0) {
343 UTIL_THROW("Error: Non-positive thread count -t option");
344 }
345 T::setThreadCount(tArg);
346 }
347
348 }
349
350 /*
351 * Read parameters and initialize.
352 */
353 template <int D, class T>
354 void System<D,T>::readParameters(std::istream& in)
355 {
356 // Optionally read polymerModel_ enum value, set the global value
358 polymerModel_ = PolymerModel::Thread;
359 readOptional(in, "polymerModel", polymerModel_);
360
361 // Set the global enumeration value
362 PolymerModel::setModel(polymerModel_);
363 }
364
365 // Check number of times the global polymer model has been set.
366 // Retain this value so we can check at the end of this function
367 // that it was not set again within the function.
368
369 int nSetPolymerModel = PolymerModel::nSet();
370
371 // Read the Mixture{ ... } block
372 readParamComposite(in, mixture_());
373 hasMixture_ = true;
374
375 int nm = mixture_().nMonomer();
376 int np = mixture_().nPolymer();
377 int ns = mixture_().nSolvent();
378 UTIL_CHECK(nm > 0);
379 UTIL_CHECK(np >= 0);
380 UTIL_CHECK(ns >= 0);
381 UTIL_CHECK(np + ns > 0);
382
383 // Read the Interaction{ ... } block
384 interaction().setNMonomer(nm);
385 readParamComposite(in, interaction());
386
387 // Read the Domain{ ... } block
388 readParamComposite(in, domain_());
389 UTIL_CHECK(domain_().mesh().size() > 0);
390 UTIL_CHECK(domain_().unitCell().nParameter() > 0);
391 UTIL_CHECK(domain_().unitCell().lattice() != UnitCell<D>::Null);
392 domain_().fieldIo().setNMonomer(nm);
393
394 // Setup the mixture
395 mixture_().associate(domain_().mesh(), domain_().fft(),
396 domain_().unitCell(), domain_().waveList());
397 mixture_().setFieldIo(domain_().fieldIo());
398 mixture_().allocate();
399
400 // Allocate memory for field containers in r-grid form
401 allocateFieldsGrid();
402
403 // Optionally read and construct an Environment
404 std::string className;
405 bool isEnd;
406 environmentPtr_ =
407 environmentFactoryPtr_->readObjectOptional(in, *this,
408 className, isEnd);
409 if (!environmentPtr_ && ParamComponent::echo()) {
410 Log::file() << indent() << " Environment{ [absent] }\n";
411 }
412 if (environmentPtr_) {
413 environment().setNParams(domain_().unitCell().nParameter());
414 }
415
416 // Optionally read and construct an Iterator
417 if (!isEnd) {
418 iteratorPtr_ =
419 iteratorFactoryPtr_->readObjectOptional(in, *this,
420 className, isEnd);
421 if (iteratorPtr_) {
422 if (iteratorPtr_->isSymmetric()) {
423 UTIL_CHECK(domain_().hasGroup());
424 }
425 } else {
426 if (ParamComponent::echo()) {
427 Log::file() << indent() << " Iterator{ [absent] }\n";
428 }
429 }
430 }
431
432 // Optionally read and construct a Sweep (if an iterator exists)
433 if (hasIterator() && !isEnd) {
434 sweepPtr_ =
435 sweepFactoryPtr_->readObjectOptional(in, *this,
436 className, isEnd);
437 if (!sweepPtr_ && ParamComponent::echo()) {
438 Log::file() << indent() << " Sweep{ [absent] }\n";
439 }
440 }
441
442 // Optionally read and construct a Simulator
443 if (!isEnd) {
444 simulatorPtr_ =
445 simulatorFactoryPtr_->readObjectOptional(in, *this,
446 className, isEnd);
447 if (simulatorPtr_) {
448 w().signal().addObserver(simulator(), &Simulator<D,T>::clearData);
449 } else
450 if (ParamComponent::echo()) {
451 Log::file() << indent() << " Simulator{ [absent] }\n";
452 }
453 }
454
455 // Check that the polymer model was not modified after initialization
456 UTIL_CHECK(PolymerModel::nSet() == nSetPolymerModel);
457
458 // Note: The main pscf_rpc or pscf_rpg program can irreversibly lock the
459 // global polymer model after reading the parameter file, to also prohibit
460 // later changes. The model is not locked here to allow repeated calls to
461 // this function during unit testing.
462 }
463
464 /*
465 * Read parameter file (including open and closing brackets).
466 */
467 template <int D, class T>
468 void System<D,T>::readParam(std::istream& in)
469 {
470 readBegin(in, className().c_str());
471 readParameters(in);
472 readEnd(in);
473 }
474
475 /*
476 * Read default parameter file.
477 */
478 template <int D, class T>
480 { readParam(fileMaster().paramFile()); }
481
482 /*
483 * Read and execute commands from a specified command file.
484 */
485 template <int D, class T>
486 int System<D,T>::readCommands(std::istream &in)
487 {
488 UTIL_CHECK(isAllocatedGrid_);
489 std::string command, filename, inFileName, outFileName;
490 FieldIo<D,T> const & fieldIo = domain_().fieldIo();
491
492 // Set to 1 if a command fails, which also stops execution
493 int status = 0;
494
495 bool readNext = true;
496 while (readNext) {
497
498 // Stop when no further command can be read. (A test of eof()
499 // here would skip a last command that is not followed by a
500 // newline.)
501 in >> command;
502 if (in.fail()) {
503 break;
504 }
505 Log::file() << command << std::endl;
506
507 if (command == "FINISH") {
508 Log::file() << std::endl;
509 readNext = false;
510 } else
511 if (command == "READ_W_BASIS") {
512 readEcho(in, filename);
513 w().readBasis(filename);
514 UTIL_CHECK(domain_().unitCell().isInitialized());
515 UTIL_CHECK(domain_().basis().isInitialized());
516 UTIL_CHECK(!domain_().waveList().hasKSq());
517 UTIL_CHECK(isAllocatedBasis_);
518 UTIL_CHECK(!c().hasData());
519 UTIL_CHECK(!scft().hasData());
520 } else
521 if (command == "READ_W_RGRID") {
522 readEcho(in, filename);
523 w().readRGrid(filename);
524 UTIL_CHECK(domain_().unitCell().isInitialized());
525 UTIL_CHECK(!domain_().waveList().hasKSq());
526 UTIL_CHECK(!c().hasData());
527 UTIL_CHECK(!scft().hasData());
528 } else
529 if (command == "SET_UNIT_CELL") {
530 UnitCell<D> unitCell;
531 in >> unitCell;
532 checkCommandInput(in, command);
533 Log::file() << " " << unitCell << std::endl;
534 setUnitCell(unitCell);
535 UTIL_CHECK(domain_().unitCell().isInitialized());
536 UTIL_CHECK(!domain_().waveList().hasKSq());
537 UTIL_CHECK(!c().hasData());
538 UTIL_CHECK(!scft().hasData());
539 } else
540 if (command == "COMPUTE") {
541 // Solve the modified diffusion equation, without iteration
542 compute();
543 } else
544 if (command == "ITERATE") {
545 // Attempt to iteratively solve a single SCFT problem
546 bool isContinuation = false;
547 int fail = iterate(isContinuation);
548 if (fail) {
549 status = 1;
550 readNext = false;
551 }
552 } else
553 if (command == "SWEEP") {
554 // Attempt to solve a sequence of SCFT problems along a path
555 // through parameter space
556 sweep();
557 } else
558 if (command == "COMPRESS") {
559 // Impose incompressibility
560 UTIL_CHECK(hasSimulator());
561 int fail = simulator().compressor().compress();
562 // As for ITERATE, stop on failure: later commands would act
563 // on fields that do not satisfy the constraint
564 if (fail) {
565 Log::file() << std::endl
566 << "COMPRESS failed; no further commands "
567 << "are executed" << std::endl;
568 status = 1;
569 readNext = false;
570 }
571 } else
572 if (command == "SIMULATE") {
573 // Perform a field theoretic simulation
574 int nStep;
575 in >> nStep;
576 checkCommandInput(in, command);
577 Log::file() << " " << nStep << "\n";
578 simulate(nStep);
579 } else
580 if (command == "ANALYZE" || command == "ANALYZE_TRAJECTORY") {
581 // Read and analyze a field trajectory file
582 int min, max;
583 in >> min;
584 in >> max;
585 checkCommandInput(in, command);
586 Log::file() << " " << min ;
587 Log::file() << " " << max << "\n";
588 std::string classname;
589 readEcho(in, classname);
590 readEcho(in, filename);
591 UTIL_CHECK(hasSimulator());
592 simulator().analyze(min, max, classname, filename);
593 } else
594 if (command == "WRITE_PARAM") {
595 readEcho(in, filename);
596 std::ofstream file;
597 fileMaster().openOutputFile(filename, file);
598 writeParamNoSweep(file);
599 file.close();
600 } else
601 if (command == "WRITE_THERMO") {
602 readEcho(in, filename);
603 std::ofstream file;
604 fileMaster().openOutputFile(filename, file,
605 std::ios_base::app);
606 scft().write(file);
607 file.close();
608 } else
609 if (command == "WRITE_STRESS") {
610 readEcho(in, filename);
611 std::ofstream file;
612 UTIL_CHECK(c().hasData());
613 if (!mixture_().hasStress()) {
614 computeStress();
615 }
616 fileMaster().openOutputFile(filename, file,
617 std::ios_base::app);
618 mixture_().writeStress(file);
619 if (hasEnvironment()) {
620 environment().writeStress(file);
621 }
622 file.close();
623 } else
624 if (command == "WRITE_W_BASIS") {
625 readEcho(in, filename);
626 w().writeBasis(filename);
627 } else
628 if (command == "WRITE_W_RGRID") {
629 readEcho(in, filename);
630 w().writeRGrid(filename);
631 } else
632 if (command == "WRITE_C_BASIS") {
633 readEcho(in, filename);
634 c().writeBasis(filename);
635 } else
636 if (command == "WRITE_C_RGRID") {
637 readEcho(in, filename);
638 c().writeRGrid(filename);
639 } else
640 if (command == "WRITE_BLOCK_C_RGRID") {
641 readEcho(in, filename);
642 UTIL_CHECK(c().hasData());
643 mixture_().writeBlockCRGrid(filename);
644 } else
645 if (command == "WRITE_Q_SLICE") {
646 int polymerId, blockId, directionId, segmentId;
647 readEcho(in, filename);
648 in >> polymerId;
649 in >> blockId;
650 in >> directionId;
651 in >> segmentId;
652 checkCommandInput(in, command);
653 Log::file() << Str("polymer ID ", 21) << polymerId << "\n"
654 << Str("block ID ", 21) << blockId << "\n"
655 << Str("direction ID ", 21) << directionId
656 << "\n"
657 << Str("segment ID ", 21) << segmentId
658 << std::endl;
659 UTIL_CHECK(c().hasData());
660 mixture_().writeQSlice(filename, polymerId, blockId,
661 directionId, segmentId);
662 } else
663 if (command == "WRITE_Q_TAIL") {
664 readEcho(in, filename);
665 int polymerId, blockId, directionId;
666 in >> polymerId;
667 in >> blockId;
668 in >> directionId;
669 checkCommandInput(in, command);
670 Log::file() << Str("polymer ID ", 21) << polymerId << "\n"
671 << Str("block ID ", 21) << blockId << "\n"
672 << Str("direction ID ", 21) << directionId
673 << "\n";
674 UTIL_CHECK(c().hasData());
675 mixture_().writeQTail(filename, polymerId, blockId, directionId);
676 } else
677 if (command == "WRITE_Q") {
678 readEcho(in, filename);
679 int polymerId, blockId, directionId;
680 in >> polymerId;
681 in >> blockId;
682 in >> directionId;
683 checkCommandInput(in, command);
684 Log::file() << Str("polymer ID ", 21) << polymerId << "\n"
685 << Str("block ID ", 21) << blockId << "\n"
686 << Str("direction ID ", 21) << directionId
687 << "\n";
688 UTIL_CHECK(c().hasData());
689 mixture_().writeQ(filename, polymerId, blockId, directionId);
690 } else
691 if (command == "WRITE_Q_ALL") {
692 readEcho(in, filename);
693 UTIL_CHECK(c().hasData());
694 mixture_().writeQAll(filename);
695 } else
696 if (command == "WRITE_STARS") {
697 readEcho(in, filename);
698 domain_().writeStars(filename);
699 } else
700 if (command == "WRITE_WAVES") {
701 readEcho(in, filename);
702 domain_().writeWaves(filename);
703 } else
704 if (command == "WRITE_GROUP") {
705 readEcho(in, filename);
706 domain_().writeGroup(filename);
707 } else
708 if (command == "BASIS_TO_RGRID") {
709 readEcho(in, inFileName);
710 readEcho(in, outFileName);
711 fieldIo.convertBasisToRGrid(inFileName, outFileName);
712 } else
713 if (command == "RGRID_TO_BASIS") {
714 readEcho(in, inFileName);
715 readEcho(in, outFileName);
716 fieldIo.convertRGridToBasis(inFileName, outFileName);
717 } else
718 if (command == "KGRID_TO_RGRID") {
719 readEcho(in, inFileName);
720 readEcho(in, outFileName);
721 fieldIo.convertKGridToRGrid(inFileName, outFileName);
722 } else
723 if (command == "RGRID_TO_KGRID") {
724 readEcho(in, inFileName);
725 readEcho(in, outFileName);
726 fieldIo.convertRGridToKGrid(inFileName, outFileName);
727 } else
728 if (command == "BASIS_TO_KGRID") {
729 readEcho(in, inFileName);
730 readEcho(in, outFileName);
731 fieldIo.convertBasisToKGrid(inFileName, outFileName);
732 } else
733 if (command == "KGRID_TO_BASIS") {
734 readEcho(in, inFileName);
735 readEcho(in, outFileName);
736 fieldIo.convertKGridToBasis(inFileName, outFileName);
737 } else
738 if (command == "CHECK_RGRID_SYMMETRY") {
739 double epsilon;
740 readEcho(in, inFileName);
741 readEcho(in, epsilon);
742 bool hasSymmetry;
743 hasSymmetry = fieldIo.hasSymmetry(inFileName, epsilon);
744 if (hasSymmetry) {
745 Log::file() << std::endl
746 << "Symmetry of r-grid file matches this space group"
747 << std::endl << std::endl;
748 } else {
749 Log::file() << std::endl
750 << "Symmetry of r-grid file does not match this\n"
751 << "space group to within error threshold of "
752 << Dbl(epsilon) << " ." << std::endl << std::endl;
753 }
754 } else
755 if (command == "COMPARE_BASIS") {
756 std::string filecompare1, filecompare2;
757 readEcho(in, filecompare1);
758 readEcho(in, filecompare2);
759 fieldIo.compareFieldsBasis(filecompare1, filecompare2);
760 } else
761 if (command == "COMPARE_RGRID") {
762 std::string filecompare1, filecompare2;
763 readEcho(in, filecompare1);
764 readEcho(in, filecompare2);
765 fieldIo.compareFieldsRGrid(filecompare1, filecompare2);
766 } else
767 if (command == "SCALE_BASIS") {
768 double factor;
769 readEcho(in, inFileName);
770 readEcho(in, outFileName);
771 readEcho(in, factor);
772 fieldIo.scaleFieldsBasis(inFileName, outFileName, factor);
773 } else
774 if (command == "SCALE_RGRID") {
775 double factor;
776 readEcho(in, inFileName);
777 readEcho(in, outFileName);
778 readEcho(in, factor);
779 fieldIo.scaleFieldsRGrid(inFileName, outFileName, factor);
780 } else
781 if (command == "EXPAND_RGRID_DIMENSION") {
782 readEcho(in, inFileName);
783 readEcho(in, outFileName);
784
785 // Read expanded spatial dimension d
786 int d;
787 in >> d;
788 checkCommandInput(in, command);
789 UTIL_CHECK(d > D);
790 UTIL_CHECK(d <= 3);
791 Log::file() << Str("Expand dimension to: ") << d << "\n";
792
793 // Read numbers of grid points along added dimensions
794 DArray<int> newGridDimensions;
795 newGridDimensions.allocate(d-D);
796 for (int i = 0; i < d-D; i++) {
797 in >> newGridDimensions[i];
798 UTIL_CHECK(newGridDimensions[i] > 0);
799 }
800 checkCommandInput(in, command);
801 Log::file()
802 << Str("Numbers of grid points in added dimensions : ");
803 for (int i = 0; i < d-D; i++) {
804 Log::file() << newGridDimensions[i] << " ";
805 }
806 Log::file() << "\n";
807
808 fieldIo.expandRGridDimension(inFileName, outFileName,
809 d, newGridDimensions);
810
811 } else
812 if (command == "REPLICATE_UNIT_CELL") {
813 readEcho(in, inFileName);
814 readEcho(in, outFileName);
815
816 // Read numbers of replicas along each direction
817 IntVec<D> replicas;
818 for (int i = 0; i < D; i++){
819 in >> replicas[i];
820 UTIL_CHECK(replicas[i] > 0);
821 }
822 checkCommandInput(in, command);
823 for (int i = 0; i < D; i++){
824 Log::file() << "Replicate unit cell in direction "
825 << i << " : ";
826 Log::file() << replicas[i] << " times ";
827 Log::file() << "\n";
828 }
829 fieldIo.replicateUnitCell(inFileName, outFileName, replicas);
830
831 } else
832 if (command == "ESTIMATE_W_BASIS") {
833 readEcho(in, inFileName);
834 readEcho(in, outFileName);
835 fieldIo.estimateWBasis(inFileName, outFileName,
836 interaction().chi());
837 } else
838 if (command == "READ_H_BASIS") {
839 readEcho(in, filename);
840 h().readBasis(filename);
841 UTIL_CHECK(!c().hasData());
842 } else
843 if (command == "READ_H_RGRID") {
844 readEcho(in, filename);
845 h().readRGrid(filename);
846 UTIL_CHECK(!c().hasData());
847 } else
848 if (command == "WRITE_H_BASIS") {
849 readEcho(in, filename);
850 if (hasEnvironment() && environment().needsUpdate()) {
851 environment().generate();
852 }
853 h().writeBasis(filename);
854 } else
855 if (command == "WRITE_H_RGRID") {
856 readEcho(in, filename);
857 if (hasEnvironment() && environment().needsUpdate()) {
858 environment().generate();
859 }
860 h().writeRGrid(filename);
861 } else
862 if (command == "READ_MASK_BASIS") {
863 readEcho(in, filename);
864 mask().readBasis(filename);
865 } else
866 if (command == "READ_MASK_RGRID") {
867 readEcho(in, filename);
868 mask().readRGrid(filename);
869 } else
870 if (command == "WRITE_MASK_BASIS") {
871 readEcho(in, filename);
872 if (hasEnvironment() && environment().needsUpdate()) {
873 environment().generate();
874 }
875 mask().writeBasis(filename);
876 } else
877 if (command == "WRITE_MASK_RGRID") {
878 readEcho(in, filename);
879 if (hasEnvironment() && environment().needsUpdate()) {
880 environment().generate();
881 }
882 mask().writeRGrid(filename);
883 } else
884 if (command == "WRITE_TIMERS") {
885 readEcho(in, filename);
886 std::ofstream file;
887 fileMaster().openOutputFile(filename, file);
888 writeTimers(file);
889 file.close();
890 } else
891 if (command == "CLEAR_TIMERS") {
892 clearTimers();
893 } else {
894 Log::file() << "Error: Unknown command "
895 << command << std::endl;
896 status = 1;
897 readNext = false;
898 }
899 }
900 return status;
901 }
902
903 /*
904 * Read and execute commands from the default command file.
905 */
906 template <int D, class T>
908 {
909 if (fileMaster().commandFileName().empty()) {
910 UTIL_THROW("Empty command file name");
911 }
912 return readCommands(fileMaster().commandFile());
913 }
914
915 // Primary Field Theory Computations
916
917 /*
918 * Solve MDE for current w fields, without iteration.
919 */
920 template <int D, class T>
921 void System<D,T>::compute(bool needStress)
922 {
923 // Preconditions
924 UTIL_CHECK(isAllocatedGrid_);
925 UTIL_CHECK(w().isAllocatedRGrid());
926 UTIL_CHECK(c().isAllocatedRGrid());
927 UTIL_CHECK(w().hasData());
928 clearCFields();
929
930 // Make sure Environment is up-to-date
931 if (hasEnvironment()) {
932 if (environment().needsUpdate()) {
933 environment().generate();
934 }
935 }
936
937 // Solve the modified diffusion equation (without iteration)
938 mixture_().compute(w().rgrid(), c_().rgrid(), mask().phiTot());
939 mixture_().setIsSymmetric(w().isSymmetric());
940 c_().setHasData(true);
941 scft().clear();
942
943 // If w fields are symmetric, compute basis components for c fields
944 if (w().isSymmetric()) {
945 UTIL_CHECK(c().isAllocatedBasis());
946 domain_().fieldIo().convertRGridToBasis(c().rgrid(), c_().basis(),
947 false);
948 c_().setIsSymmetric(true);
949 }
950
951 // Compute stress if needed
952 if (needStress) {
954 }
955 }
956
957 /*
958 * Compute SCFT stress for current fields.
959 */
960 template <int D, class T>
962 {
963 // Compute and store standard Mixture stress
964 if (!mixture_().hasStress()) {
965 mixture_().computeStress(mask().phiTot());
966 }
967
968 // If necessary, compute and store Environment stress
969 if (hasEnvironment()) {
970 if (!environment().hasStress()) {
971 if (hasIterator()) {
972 environment().computeStress(mixture_(),
973 iterator().flexibleParams());
974 } else {
975 // Without an iterator the unit cell is rigid
976 FSArray<bool,6> flexibleParams;
977 int nParameter = domain_().unitCell().nParameter();
978 for (int i = 0; i < nParameter; ++i) {
979 flexibleParams.append(false);
980 }
981 environment().computeStress(mixture_(), flexibleParams);
982 }
983 }
984 }
985 }
986
987 /*
988 * Iteratively solve a SCFT problem.
989 */
990 template <int D, class T>
991 int System<D,T>::iterate(bool isContinuation)
992 {
993 // Preconditions
995 UTIL_CHECK(w().hasData());
996 clearCFields();
997
998 Log::file() << std::endl;
999 Log::file() << std::endl;
1000
1001 // Make sure Environment is up-to-date
1002 if (hasEnvironment()) {
1003 if (environment().needsUpdate()) {
1004 environment().generate();
1005 }
1006 }
1007
1008 // Check space-group symmetry requirements
1009 if (iterator().isSymmetric()) {
1010 UTIL_CHECK(isAllocatedBasis_);
1012 }
1013
1014 // Call iterator (return 0 for convergence, 1 for failure)
1015 int error = iterator().solve(isContinuation);
1016 UTIL_CHECK(c().hasData());
1017
1018 // If converged, compute related thermodynamic properties
1019 if (!error) {
1020 scft().compute();
1021 scft().write(Log::file());
1022 if (!iterator().isFlexible()) {
1023 if (!mixture_().hasStress()) {
1024 computeStress();
1025 }
1026 mixture_().writeStress(Log::file());
1027 if (hasEnvironment()) {
1028 environment().writeStress(Log::file());
1029 }
1030 }
1031 }
1032
1033 return error;
1034 }
1035
1036 /*
1037 * Perform an SCFT sweep along a path in parameter space.
1038 */
1039 template <int D, class T>
1041 {
1042 // Preconditions
1045 UTIL_CHECK(w().hasData());
1046 if (iterator().isSymmetric()) {
1047 UTIL_CHECK(isAllocatedBasis_);
1049 }
1050
1051 Log::file() << std::endl;
1052 Log::file() << std::endl;
1053
1054 // Perform sweep
1055 sweepPtr_->sweep();
1056 }
1057
1058 /*
1059 * Perform a field theoretic simulation of nStep steps.
1060 */
1061 template <int D, class T>
1063 {
1064 UTIL_CHECK(nStep > 0);
1066 clearCFields();
1067
1068 simulator().simulate(nStep);
1069 }
1070
1071 /*
1072 * Mark c-fields and free energy as outdated/invalid.
1073 */
1074 template <int D, class T>
1076 {
1077 c_().setHasData(false);
1078 scft().clear();
1079 if (hasEnvironment()) {
1080 environment().clearStress();
1081 }
1082 }
1083
1084 /*
1085 * Check if all field inputs are symmetric under space group.
1086 *
1087 * Precondition to use of a symmetric SCFT iterator.
1088 */
1089 template <int D, class T>
1091 {
1092 if (!w().hasData() || !w().isSymmetric()) {
1093 return false;
1094 }
1095 if (h().hasData() && !h().isSymmetric()) {
1096 return false;
1097 }
1098 if (mask().hasData() && !mask().isSymmetric()) {
1099 return false;
1100 }
1101 return true;
1102 }
1103
1104 // Unit Cell Modifiers
1105
1106 /*
1107 * Set the system unit cell.
1108 */
1109 template <int D, class T>
1111 {
1112 // Preconditions
1113 UTIL_CHECK(domain_().lattice() != UnitCell<D>::Null);
1114 UTIL_CHECK(domain_().lattice() == unitCell.lattice());
1115
1116 // Set system unit cell, using UnitCell<D> assignment operator
1117 domain_().unitCell() = unitCell;
1118
1119 // If necessary, make basis
1120 if (domain_().hasGroup() && !domain_().basis().isInitialized()) {
1121 domain_().makeBasis();
1122 }
1123
1124 // Postconditions
1125 UTIL_CHECK(domain_().unitCell().isInitialized());
1126 UTIL_CHECK(domain_().unitCell().lattice() == domain_().lattice());
1127 if (domain_().hasGroup()) {
1128 UTIL_CHECK(domain_().basis().isInitialized());
1129 UTIL_CHECK(isAllocatedBasis_);
1130 }
1131 UTIL_CHECK(!domain_().waveList().hasKSq());
1132 }
1133
1134 /*
1135 * Set parameters of the system unit cell.
1136 */
1137 template <int D, class T>
1139 {
1140 // Precondition
1141 UTIL_CHECK(domain_().lattice() != UnitCell<D>::Null);
1142
1143 // Set system unit cell
1144 if (domain_().unitCell().lattice() == UnitCell<D>::Null) {
1145 domain_().unitCell().set(domain_().lattice(), parameters);
1146 } else {
1147 domain_().unitCell().setParameters(parameters);
1148 }
1149
1150 // If necessary, make basis
1151 if (domain_().hasGroup() && !domain_().basis().isInitialized()) {
1152 domain_().makeBasis();
1153 }
1154
1155 // Postconditions
1156 UTIL_CHECK(domain_().unitCell().isInitialized());
1157 UTIL_CHECK(domain_().unitCell().lattice() == domain_().lattice());
1158 if (domain_().hasGroup()) {
1159 UTIL_CHECK(domain_().basis().isInitialized());
1160 UTIL_CHECK(isAllocatedBasis_);
1161 }
1162 UTIL_CHECK(!domain_().waveList().hasKSq());
1163 }
1164
1165 /*
1166 * Notify System members that unit cell parameters have been modified.
1167 */
1168 template <int D, class T>
1170 {
1171 clearCFields();
1172 mixture_().clearUnitCellData();
1173 domain_().waveList().clearUnitCellData();
1174 if (hasEnvironment()) {
1175 environment().reset();
1176 }
1177 if (hasSimulator() && simulator().hasCompressor()) {
1178 simulator().compressor().clearCache();
1179 }
1180 }
1181
1182 // Property Output
1183
1184 /*
1185 * Write parameter file for SCFT, omitting any sweep block.
1186 */
1187 template <int D, class T>
1188 void System<D,T>::writeParamNoSweep(std::ostream& out) const
1189 {
1190 out << "System{" << std::endl;
1191 // The optional polymerModel parameter (thread by default) must be
1192 // written for the bead model
1193 if (PolymerModel::isBead()) {
1194 out << " polymerModel " << PolymerModel::model() << std::endl;
1195 }
1196 mixture().writeParam(out);
1197 interaction().writeParam(out);
1198 domain().writeParam(out);
1199 if (hasEnvironment()) {
1200 environment().writeParam(out);
1201 }
1202 if (hasIterator()) {
1203 iterator().writeParam(out);
1204 }
1205 out << "}" << std::endl;
1206 }
1207
1208 // Timer Operations
1209
1210 /*
1211 * Write timer values to output stream (computational cost).
1212 */
1213 template <int D, class T>
1214 void System<D,T>::writeTimers(std::ostream& out) const
1215 {
1216 if (hasIterator()) {
1217 iterator().outputTimers(Log::file());
1218 iterator().outputTimers(out);
1219 }
1220 if (hasSimulator()){
1221 simulator().outputTimers(Log::file());
1222 simulator().outputTimers(out);
1223 }
1224 }
1225
1226 /*
1227 * Clear state of all timers.
1228 */
1229 template <int D, class T>
1231 {
1232 if (hasIterator()) {
1233 iterator().clearTimers();
1234 }
1235 if (hasSimulator()){
1236 simulator().clearTimers();
1237 }
1238 }
1239
1240 // Private member functions
1241
1242 /*
1243 * Allocate memory for fields in grid format.
1244 */
1245 template <int D, class T>
1246 void System<D,T>::allocateFieldsGrid()
1247 {
1248 // Preconditions
1249 UTIL_CHECK(hasMixture_);
1250 int nMonomer = mixture_().nMonomer();
1251 UTIL_CHECK(nMonomer > 0);
1252 UTIL_CHECK(domain_().mesh().size() > 0);
1253 UTIL_CHECK(!isAllocatedGrid_);
1254
1255 // Alias for mesh dimensions
1256 IntVec<D> const & dimensions = domain_().mesh().dimensions();
1257
1258 // Allocate w (chemical potential) fields
1259 w().setNMonomer(nMonomer);
1260 w().allocateRGrid(dimensions);
1261
1262 // Allocate c (monomer concentration) fields
1263 c_().setNMonomer(nMonomer);
1264 c_().allocateRGrid(dimensions);
1265
1266 // Set nMonomer for external field container
1267 h().setNMonomer(nMonomer);
1268
1269 // If hasEnvironment(), allocate mask and h fields
1270 if (hasEnvironment()) {
1271 if (environment().generatesMask()) {
1272 mask().allocateRGrid(dimensions);
1273 }
1274 if (environment().generatesExternalFields()) {
1275 h().allocateRGrid(dimensions);
1276 }
1277 }
1278
1279 isAllocatedGrid_ = true;
1280 }
1281
1282 /*
1283 * Allocate memory for fields in basis format.
1284 */
1285 template <int D, class T>
1286 void System<D,T>::allocateFieldsBasis()
1287 {
1288 // Preconditions and constants
1289 UTIL_CHECK(hasMixture_);
1290 const int nMonomer = mixture_().nMonomer();
1291 UTIL_CHECK(nMonomer > 0);
1292 UTIL_CHECK(domain_().mesh().size() > 0);
1293 UTIL_CHECK(domain_().hasGroup());
1294 UTIL_CHECK(domain_().basis().isInitialized());
1295 const int nBasis = domain_().basis().nBasis();
1296 UTIL_CHECK(nBasis > 0);
1297 UTIL_CHECK(isAllocatedGrid_);
1298 UTIL_CHECK(!isAllocatedBasis_);
1299
1300 // Allocate basis fields in w and c field containers
1301 w().allocateBasis(nBasis);
1302 c_().allocateBasis(nBasis);
1303
1304 // If hasEnvironment(), allocate mask and h fields
1305 if (hasEnvironment()) {
1306 if (environment().generatesMask()) {
1307 mask().allocateBasis(nBasis);
1308 }
1309 if (environment().generatesExternalFields()) {
1310 h().allocateBasis(nBasis);
1311 }
1312 }
1313
1314 isAllocatedBasis_ = true;
1315 }
1316
1317 /*
1318 * Read a filename string and echo to log file (used in readCommands).
1319 */
1320 template <int D, class T>
1321 void System<D,T>::readEcho(std::istream& in, std::string& string) const
1322 {
1323 in >> string;
1324 if (in.fail()) {
1325 UTIL_THROW("Unable to read a string parameter.");
1326 }
1327 Log::file() << " " << Str(string, 20) << std::endl;
1328 }
1329
1330 /*
1331 * Read floating point number, echo to log file (used in readCommands).
1332 */
1333 template <int D, class T>
1334 void System<D,T>::readEcho(std::istream& in, double& value) const
1335 {
1336 in >> value;
1337 if (in.fail()) {
1338 UTIL_THROW("Unable to read floating point parameter.");
1339 }
1340 Log::file() << " " << Dbl(value, 20) << std::endl;
1341 }
1342
1343} // namespace Rp
1344} // namespace Pscf
1345#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Interaction(bool isCompressible=false)
Constructor.
CFields()
Constructor.
Definition CFields.tpp:26
Domain()
Constructor.
Definition Domain.tpp:30
EnvironmentFactory(System< D, T > &system)
Constructor.
File input/output, format conversions and other utilities for fields.
void compareFieldsBasis(DArray< DArray< double > > const &field1, DArray< DArray< double > > const &field2) const
Compare array of fields in basis form, write a report to Log file.
Definition FieldIo.tpp:1041
void scaleFieldsRGrid(DArray< RField< D, T > > &fields, double factor) const
Scale an array of r-grid fields by a scalar.
Definition FieldIo.tpp:1167
virtual bool hasSymmetry(RFieldDft< D, T > const &in, double epsilon=1.0e-8, bool verbose=true) const
Check if a k-grid field has the declared space group symmetry.
Definition FieldIo.tpp:974
void convertRGridToBasis(RField< D, T > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const
Convert a single field from r-grid to basis form.
Definition FieldIo.tpp:819
void scaleFieldsBasis(DArray< DArray< double > > &fields, double factor) const
Multiply an array of fields in basis format by a real scalar.
Definition FieldIo.tpp:1122
virtual void convertBasisToKGrid(DArray< double > const &components, RFieldDft< D, T > &dft) const
Convert a single field from basis to Fourier (k-grid) form.
Definition FieldIo.tpp:633
virtual void expandRGridDimension(std::ostream &out, DArray< RField< D, T > > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const
Increase D for an array of r-grid fields, write to ostream.
Definition FieldIo.tpp:1317
void convertBasisToRGrid(DArray< double > const &in, RField< D, T > &out) const
Convert a single field from basis to r-grid format.
Definition FieldIo.tpp:767
void convertRGridToKGrid(DArray< RField< D, T > > const &in, DArray< RFieldDft< D, T > > &out) const
Convert an array of fields from r-grid to k-grid (Fourier) format.
Definition FieldIo.tpp:905
void estimateWBasis(DMatrix< double > const &chi, DArray< DArray< double > > &fields) const
Convert c fields to estimated w fields, in basis format.
Definition FieldIo.tpp:1203
void convertKGridToRGrid(DArray< RFieldDft< D, T > > const &in, DArray< RField< D, T > > &out) const
Convert an array of field from k-grid to r-grid format.
Definition FieldIo.tpp:878
virtual void convertKGridToBasis(RFieldDft< D, T > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const
Convert a single field from Fourier (k-grid) to basis form.
Definition FieldIo.tpp:699
virtual void replicateUnitCell(std::ostream &out, DArray< RField< D, T > > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const
Write r-grid fields in a replicated unit cell to std::ostream.
Definition FieldIo.tpp:1289
virtual void compareFieldsRGrid(DArray< RField< D, T > > const &field1, DArray< RField< D, T > > const &field2) const
Compare two fields in r-grid form, write a report to Log file.
Definition FieldIo.tpp:1073
IteratorFactory(System< D, T > &system)
Constructor.
Mask()
Constructor.
Definition Mask.tpp:33
Mixture()
Default constructor.
ScftThermo(System< D, T > const &system)
Constructor.
SimulatorFactory(System< D, T > &system)
Constructor.
void clearData()
Clear field eigen-components and Hamiltonian components.
SweepFactory(System< D, T > &system)
Constructor.
int readCommands()
Read and process commands from the default command file.
Definition System.tpp:907
void simulate(int nStep)
Perform a field theoretic simulation (PS-FTS).
Definition System.tpp:1062
Simulator< D, T > const & simulator() const
Get the Simulator (const).
Environment const & environment() const
Get the Environment (const).
Mask< D, CPT > const & mask() const
bool hasSimulator() const
Does this system have a Simulator?
System()
Constructor.
Definition System.tpp:85
void computeStress()
Compute SCFT stress.
Definition System.tpp:961
CFields< D, CPT > const & c() const
bool hasEnvironment() const
Does this system have an Environment?
~System()
Destructor.
Definition System.tpp:204
FileMaster const & fileMaster() const
bool hasSymmetricInputFields()
Are the w fields, external fields and mask (if any) all symmetric?
Definition System.tpp:1090
bool hasSweep() const
Does this system have a Sweep?
WFields< D, CPT > const & h() const
int readCommands(std::istream &in)
Read and process commands from an input stream.
Definition System.tpp:486
ScftThermo< D, T > const & scft() const
Get the ScftThermo object (const).
void clearUnitCellData()
Notify System members that unit cell parameters have been modified.
Definition System.tpp:1169
void clearCFields()
Mark c-fields, propagators and free energies as outdated.
Definition System.tpp:1075
virtual void readParam(std::istream &in)
Read input parameters (with opening and closing lines).
Definition System.tpp:468
void setUnitCell(UnitCell< D > const &unitCell)
Set parameters of the associated unit cell.
Definition System.tpp:1110
virtual void readParameters(std::istream &in)
Read body of parameter block (without opening and closing lines).
Definition System.tpp:354
void compute(bool needStress=false)
Solve the modified diffusion equation once, without iteration.
Definition System.tpp:921
int iterate(bool isContinuation=false)
Iteratively solve a SCFT problem.
Definition System.tpp:991
void readParam()
Read input parameters from default param file.
Definition System.tpp:479
void clearTimers()
Clear all timers.
Definition System.tpp:1230
Interaction const & interaction() const
Get the Interaction (const).
Mixture< D, T > const & mixture() const
Get the Mixture (const).
WaveList< D, T > & waveList()
Get the WaveList (non-const).
bool hasIterator() const
Does this system have an Iterator?
MixtureModifier< D, CPT > & mixtureModifier()
void writeParamNoSweep(std::ostream &out) const
Write partial parameter file to an ostream.
Definition System.tpp:1188
void writeTimers(std::ostream &out) const
Write timer information to an output stream.
Definition System.tpp:1214
Domain< D, T > const & domain() const
Get the Domain (const).
WFields< D, CPT > const & w() const
void setOptions(int argc, char **argv)
Process command line options.
Definition System.tpp:248
Iterator< D, T > const & iterator() const
Get the Iterator (const).
WFields()
Constructor.
Definition WFields.tpp:37
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition UnitCell.h:55
Dynamically allocatable contiguous array template.
Definition DArray.h:32
void allocate(int capacity)
Allocate the underlying C array.
Definition DArray.h:262
Dbl()
Default constructor.
Definition Dbl.cpp:17
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
void append(Data const &data)
Append data to the end of the array.
Definition FSArray.h:261
FileMaster()
Constructor.
static std::ostream & file()
Get log ostream by reference.
Definition Log.cpp:59
std::string indent() const
Return indent string for this object (string of spaces).
static bool echo()
Get echo parameter.
static void setEcho(bool echo=true)
Enable or disable echoing for all subclasses of ParamComponent.
Begin & readBegin(std::istream &in, const char *label, bool isRequired=true)
Add and read a class label and opening bracket.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
std::string className() const
Get class name string.
End & readEnd(std::istream &in)
Add and read the closing bracket.
Notifier (or subject) in the Observer design pattern.
Definition Signal.h:39
void addObserver(Observer &observer, void(Observer::*methodPtr)(const T &))
Register an observer.
Definition Signal.h:111
Str()
Default constructor.
Definition Str.cpp:17
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition global.h:49
bool hasSymmetry(AT const &in, Basis< D > const &basis, IntVec< D > const &dftDimensions, double epsilon=1.0e-8, bool verbose=true)
Check if a k-grid field has the declared space group symmetry.
double min(Array< double > const &in)
Get minimum of array elements .
Definition Reduce.cpp:276
double max(Array< double > const &in)
Get maximum of array elements (real).
Definition Reduce.cpp:229
Enumeration and functions to specify a model for polymer chains.
int nSet()
How many times has setModel been called?
Type model()
Get the global polymer model type enumeration value.
void setModel(Type model)
Set the global polymer model enumeration value.
bool isBead()
Is the bead model in use ?
bool isLocked()
Has the model type been locked (i.e., made immutable) ?
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.
void set(BracketPolicy::Type policy)
Set policy regarding use of bracket delimiters on arrays.