This pull request adds a Mask object (called mask) and a wFieldContainer representing external fields (called h) to System (all in pspc):
The ability to read and write these fields via command file commands is added
Their usage is tested and shown to work correctly
The filmIterator class is fixed so it uses these System fields rather than its own locally stored fields
The Iterator class no longer has methods pertaining to masks or external fields
Non-const accessor functions for the mask and external field containers are added to System
hasMask() and hasExternalFields() methods are added to System
Mask now has a member function phiTot() that calculates the volume fraction of the unit cell occupied by polymers/solvents. This function works even if Mask is not allocated (it returns 1, which is correct for a system without a mask).
phiTot() is used to scale certain values (e.g., Q) by a multiplicative factor to account for the volume that polymers are restricted from occupying due to the mask. This is tested and works properly.
FilmIterator no longer modifies the phi values of each species to account for the volume occupied by the wall, because we are accounting for this effect in Mixture∷compute using Mask::phiTot() instead.
Additional features that are related to the handling of fields are added to the software as well, to improve the user interface with these new fields:
WFieldContainer and Mask are given readBasis() and readRGrid() methods, and these are used whenever we read data from a file. The old System methods readWBasis and readWRGrid are still kept, and should be used to read data into the w object because they also properly set the System∷hasCFields private member.
Since users can manually input masks and external fields, users can now also manually define flexibleParams in AmIterator, as an alternative to isFlexible. The user input is an array of Booleans with nParameter entries, e.g. flexibleParams[ 0 1 0 1], which will make the second and fourth lattice parameters flexible and the other two rigid.
filmIterator needs to check that flexibleParams is compatible with the thin film constraint, so it has been updated to work correctly regardless of how the user declares the flexible lattice parameters.
The process of updating the UnitCell object when reading a field file header in FieldIo∷readFieldHeader is clarified, so users will know what is happening if there is ever a conflict between the existing data and the data in the field file header.
the space group, crystal system, and nParameters must match the expected values or else the code will throw an error.
the lattice parameters may be different than those currently stored in the UnitCell; in this case, the lattice parameters from the field file header are used and a Notice statement is printed to alert the user that this update is occurring.
If readFieldHeader is passed an empty UnitCell object, the checks are not performed and the data from the file header are just read directly into the UnitCell.
FieldIo now has methods to read/write a single field in basis format, which did not exist before. It also has methods to perform k-grid/r-grid conversions on a single field, which did not exist before.
Users can now perform RGRID_TO_BASIS or KGRID_TO_BASIS conversions even if the input file does not have the correct symmetry. In this case there will be a warning statement printed indicating the error between the input and output fields, and telling the user that the output field will be a “symmetrized” version of their input field.
To do this, FieldIo∷hasSymmetry is modified to have a “verbose” input flag. If verbose = true and the r-grid does not have the right symmetry, it will print the maximum coefficient of a cancelled star and the maximum error of a coefficient for an uncancelled star, so users can see how close the r-grid is to having the right symmetry. We then use this function before converting to basis, and print the error if it is above 1e-8.
Other small bugfixes and edits unrelated to the above updates are included as well:
The “chi” matrix in FilmIterator has been changed to two separate arrays, “chiBottom” and “chiTop”. They now have separate sweep parameter names, “chi_bottom” and “chi_top”, rather than being combined as “wall_chi”.
Free energy is now decomposed into three contributions: ideal gas in a potential field, multi-chain interaction, and external field interaction. The three contributions are printed by writeThermo (or two if no external field is present) right after we print the overall value of fHelmholtz.
A new private member diverged_ of AmIteratorTmpl is added as a way to flag whether the calculation has diverged, which occurs when any of the residuals becomes NaN. In this case, the previous code would consider this a successful convergence, but with the new code added it will now stop iterating and indicate that the convergence failed.
Additionally, our fieldComparison classes did not work if either field had NaN values, so this was fixed as well. If either field is NaN, the fieldComparison sets 1e8 as the error and exits the compare function, since there is really no value in comparing a NaN field to anything.
A bug was caught in System∷guessWFromC, in which we were using tmpFieldsBasis_ twice in the same calculation, overwriting itself and causing bad data to be output. This is fixed by creating a new, second temporary field within the scope of this method.
KGRID_TO_BASIS and BASIS_TO_KGRID called the wrong conversion functions in System∷readCommands, this was fixed.
Fix bug so that filmIterator is able to work with a space group that is defined in a local file rather than in the main space groups directory.
All corresponding documentation has been updated. Unit tests have been added/modified where appropriate, and all unit tests pass on both my personal laptop and on MSI.
This pull request adds a Mask object (called mask) and a wFieldContainer representing external fields (called h) to System (all in pspc):
Additional features that are related to the handling of fields are added to the software as well, to improve the user interface with these new fields:
Other small bugfixes and edits unrelated to the above updates are included as well:
All corresponding documentation has been updated. Unit tests have been added/modified where appropriate, and all unit tests pass on both my personal laptop and on MSI.