Phase Behaviors of Block Copolymers - Part 3: Macrophase Separation
import Pkg
Pkg.activate(".")
using Polymer
using Scattering
using Polyorder
using PhaseDiagram
using PolymerArchitectureMakie
using CairoMakie
using LaTeXStrings Activating project at `~/SynologyDrive/Develop/Polyorder.jl/docs/tutorial`# Suppressing displaying source code file location for @info
using Logging
global_logger(ConsoleLogger())ConsoleLogger(IJulia.IJuliaStdio{Base.PipeEndpoint}(IOContext(Base.PipeEndpoint(RawFD(49) open, 0 bytes waiting))), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (3, 3, 142704586847)), Info, Base.CoreLogging.default_metafmt, true, 0, Dict{Any, Int64}())include("common.jl")plot_density (generic function with 3 methods)Macorphase separation may happen when there are more than one component in the polymer system. Moreover, macrophase separation and microphase separation may happen simultaneously when there are least one block copolymer component in the polymer system.
PhaseDiagram.jl provides the function macrophase to compute the phase coexistence point.
DIS-DIS coexistence
First, create an SCFT model. Note that for DIS calculations, only polymer system is imoportant because FH theory is used to calculate the free energy and the chemical potential.
The polymer system is a AB/A binary blend with a symmetric AB diblock copolymer and the length of homopolymer α=0.5, χN=20.0.
model_dis_dis = let
uc = UnitCell(1.0)
lat = BravaisLattice(uc)
system = AB_A_system()
# Lattice and ds are irrelavent here, because we only interested in DIS phase
scft = NoncyclicChainSCFT(system, lat, 0.1)
PolyorderModel(scft)
end;Next, create a MacrophaseModel object with the intial guess of volume fractions for two DIS phases being 0.1 and 0.9. ϕ₀ is the initial volume fraction of the AB component before macrophase separation.
macro_dis_dis = MacrophaseModel(model_dis_dis, model_dis_dis;
phase1=DISPhase, phase2=DISPhase,
ϕ₁=0.1, ϕ₂=0.9, ϕ₀=0.6, cached=false);Finally, using an optimization algorithm enclosed in OptimOptimizer together with the macrophase function to solve the coexistence point, which is (0.0193969, 0.927374). OptimOptimizer wraps all optimization algorithms provided by the Optim.jl package. It requires 18 SCFT evaluations.
macrophase(OptimOptimizer(), macro_dis_dis; lb=[0.01, 0.6], ub=[0.6, 0.99]);[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.1 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.9 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.049477 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.925833 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.049477 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.925833 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.013965 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.909849 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.013965 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.909849 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.018031 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.938982 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.018031 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.938982 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.023692 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.924599 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.023692 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.924599 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.018071 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.926364 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.018071 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.926364 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019603 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927548 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019603 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927548 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019406 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927369 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019406 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927369 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019397 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927374 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019397 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927374 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019397 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927374 phase: DIS
[ Info:
[ Info: ======================================================Other coexistence solvers are available, including:
JSOOptimizer: optimizers provided by the JSOSolvers.jl packageOPSOptimizer: surrogate-based optimizers developed in our group.RootsOptimizer: root-finding algorithms provided by the Roots.jl package. RequiresSurrogateMacrophaseModelinstead ofMacrophaseModel.
The JSOOptimizer requires 14 SCFT evaluations.
macrophase(JSOOptimizer(), macro_dis_dis; lb=[0.01, 0.6], ub=[0.6, 0.99]);[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.1 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.9 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.01 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.99 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.015943 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.943026 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.024652 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.918515 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.01836 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.925487 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.020379 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.928707 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019262 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.92737 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019248 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927399 phase: DIS
[ Info:
[ Info: ======================================================The OPSOptimizer requires only 8 SCFT evaluations (the initial guess ignored), which reduces the computational cost by (18-8)/18=56% and (14-8)/14=43% with respect to OptimOptimizer and JSOOptimizer, respectively.
let
vecϕ01 = [0.01, 0.2] # list of initial guesses for phase 1
vecϕ02 = [0.75, 0.95] # list of initial guesses for phase 2
tol_io = 1e-8 # tol for internal optimizer
tol_oo = 1e-4 # tol for outside optimizer
ϕ1 = 0.1 # initial guess of the solution for phase 1
ϕ2 = 0.9 # initial guess of the solution for pahse 2
ϕ0 = 0.6 # the initial volume fractions of the mixing system, critical for optimizing algorithms, but not used by root finding algorithms.
io = RootsOptimizer(; x_abstol=tol_io)
oo = OPSOptimizer(vecϕ01, vecϕ02; optimizer=io, x_abstol=tol_oo)
ϕ₁, ϕ₂, _ = macrophase(oo, macro_dis_dis)
end;[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.01 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.2 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.75 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.95 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.032363 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.919318 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019367 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.92758 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.019239 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927396 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.01925 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.927397 phase: DIS
[ Info:
[ Info: ======================================================Exercises
Choose either coexistence optimizer, compute the binodal line for A/B binary blend for χN\<10.0 where A and B have same length. Note that the critical point is χN=2.0 for this case.
Repeat 1 for A/B binary blend where the length ratio between A and B is 2.
LAM-DIS coexistence
In this demonstration, we will reproduce part of result reported in Fig.3 of Ref. Mester, Z.; Lynd, N. A.; Fredrickson, G. H. Numerical Self-Consistent Field Theory of Multicomponent Polymer Blends in the Gibbs Ensemble. Soft Matter 2013, 9 (47), 11288.
begin
ds = 0.01
uc = UnitCell(7.0)
lattice = BravaisLattice(uc)
system_lam = AB_A_system(; χN=10.0, ϕAB=0.5, fA=0.45, α=1.0)
scft_lam = NoncyclicChainSCFT(system_lam, lattice, ds)
end;Polyorder.solve!(scft_lam);[ Info: ******* SCFT Simulation Start *******
[ Info: Algorithm: PicardMann iteration with α=0.2.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.0]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: number: 100
[ Info: F: 0.1757755892
[ Info: resediual norm: 0.00103
[ Info: number: 200
[ Info: F: 0.1756234785
[ Info: resediual norm: 0.000289
[ Info: number: 300
[ Info: F: 0.1756127438
[ Info: resediual norm: 8.32e-5
[ Info: number: 400
[ Info: F: 0.1756118565
[ Info: resediual norm: 2.43e-5
[ Info: number: 500
[ Info: F: 0.1756117754
[ Info: resediual norm: 7.22e-6
[ Info: number: 600
[ Info: F: 0.1756117675
[ Info: resediual norm: 2.18e-6
[ Info: final loss: 9.927483577453274e-7
[ Info: Stop triggered by EarlyStopping.Threshold(1.0e-6) stopping criterion.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.1756117669
[ Info: final loss: 9.93e-7
[ Info: final stress norm: 0.0020823856893135984
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.0]
└ * Angles: [0]
[ Info: iterations: 666
[ Info: time per iteration: 3 milliseconds, 72 microseconds, 151 nanoseconds
[ Info: Run time: 00:00:02.046052958
[ Info: =======================================plot_density(scft_lam)┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.
└ @ Makie ~/.julia/packages/Makie/PpRC2/src/scenes.jl:264Batch evaluations
We can compute the free energies for a list of $\phi_{AB}$ values.
begin
ϕABs_AB_A_lam = [0.5, 0.6, 0.7, 0.8, 0.85, 0.9, 0.92, 0.94, 0.96, 0.98]
ϕAs_AB_A_lam = 1 .- ϕABs_AB_A_lam
ϕA_AB_A_control = ϕControlParameter(:hA, system_lam)
Fs_AB_A_lam = similar(ϕAs_AB_A_lam)
μs_AB_A_lam = similar(ϕAs_AB_A_lam)
info_AB_A_lam = []
end;using Polyorder: BB, SD, SISlet
scft = Polyorder.clone(scft_lam)
for i in eachindex(ϕAs_AB_A_lam)
system = Polymer.update!(scft.system, ϕAs_AB_A_lam[i], ϕA_AB_A_control)
lat = Polyorder.lattice(scft)
scft = Polyorder.reset(scft, lat, system)
updater = VariableCell(BB(1.0), SIS(1.0))
conv, _ = cell_solve!(scft, updater)
Fs_AB_A_lam[i], μs_AB_A_lam[i] = Polyorder.F(scft), Polyorder.μ̃(scft, 1)
# Store extra information
info = (convgence=conv, ϕA=ϕAs_AB_A_lam[i],
F = Polyorder.F(scft),
Lx=first(Polyorder.unitcell(scft).edges),
Nx=first(size(first(scft.ϕfields))))
push!(info_AB_A_lam, info)
end
end[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.0]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 6.776239569878718e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.1753855179
[ Info: final loss: 6.78e-7
[ Info: final stress norm: 1.13e-7
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.2226103539773465]
└ * Angles: [0]
[ Info: iterations: 80
[ Info: time per iteration: 20 milliseconds, 56 microseconds, 96 nanoseconds
[ Info: Run time: 00:00:01.60448775
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.2226103539773465]
└ * Angles: [0]
[ Info: Final F: 0.17538551788070622
[ Info: Final loss: 6.776239569878718e-7
[ Info: Final stress: 1.1275764079807448e-7
[ Info: Total solve! calls: 8
[ Info: Total SCFT iterations: 80
[ Info: Total time: 00:00:02
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [7.2226103539773465]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.768184231380956e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.4215462056
[ Info: final loss: 8.77e-7
[ Info: final stress norm: 1.36e-9
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.861524102066409]
└ * Angles: [0]
[ Info: iterations: 150
[ Info: time per iteration: 529 microseconds, 675 nanoseconds
[ Info: Run time: 00:00:00.079451375
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.861524102066409]
└ * Angles: [0]
[ Info: Final F: 0.4215462056178785
[ Info: Final loss: 8.768184231380956e-7
[ Info: Final stress: 1.3576447730642472e-9
[ Info: Total solve! calls: 15
[ Info: Total SCFT iterations: 150
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.861524102066409]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 9.848856140002156e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.6673106306
[ Info: final loss: 9.85e-7
[ Info: final stress norm: 1.13e-7
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929819985195713]
└ * Angles: [0]
[ Info: iterations: 140
[ Info: time per iteration: 96 microseconds, 281 nanoseconds
[ Info: Run time: 00:00:00.013479375
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929819985195713]
└ * Angles: [0]
[ Info: Final F: 0.6673106306173366
[ Info: Final loss: 9.848856140002156e-7
[ Info: Final stress: 1.1327559347710169e-7
[ Info: Total solve! calls: 14
[ Info: Total SCFT iterations: 140
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929819985195713]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 6.478339360058344e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.9135518668
[ Info: final loss: 6.48e-7
[ Info: final stress norm: 8.29e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.26390965953216]
└ * Angles: [0]
[ Info: iterations: 140
[ Info: time per iteration: 156 microseconds, 789 nanoseconds
[ Info: Run time: 00:00:00.0219505
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.26390965953216]
└ * Angles: [0]
[ Info: Final F: 0.9135518668182665
[ Info: Final loss: 6.478339360058344e-7
[ Info: Final stress: 8.286513809719884e-8
[ Info: Total solve! calls: 14
[ Info: Total SCFT iterations: 140
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.26390965953216]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 7.857013743313433e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.0379038192
[ Info: final loss: 7.86e-7
[ Info: final stress norm: 1.17e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.989219186554587]
└ * Angles: [0]
[ Info: iterations: 120
[ Info: time per iteration: 99 microseconds, 647 nanoseconds
[ Info: Run time: 00:00:00.01195775
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.989219186554587]
└ * Angles: [0]
[ Info: Final F: 1.037903819167518
[ Info: Final loss: 7.857013743313433e-7
[ Info: Final stress: 1.1662838494879982e-8
[ Info: Total solve! calls: 12
[ Info: Total SCFT iterations: 120
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.989219186554587]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.977770333507324e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.1643951406
[ Info: final loss: 8.98e-7
[ Info: final stress norm: 4.77e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.730272679467624]
└ * Angles: [0]
[ Info: iterations: 190
[ Info: time per iteration: 86 microseconds, 590 nanoseconds
[ Info: Run time: 00:00:00.016452167
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.730272679467624]
└ * Angles: [0]
[ Info: Final F: 1.1643951405881336
[ Info: Final loss: 8.977770333507324e-7
[ Info: Final stress: 4.77080237612934e-8
[ Info: Total solve! calls: 19
[ Info: Total SCFT iterations: 190
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.730272679467624]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.060993367930467e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.2161406052
[ Info: final loss: 8.06e-7
[ Info: final stress norm: 2.35e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.6263155222235377]
└ * Angles: [0]
[ Info: iterations: 270
[ Info: time per iteration: 79 microseconds, 771 nanoseconds
[ Info: Run time: 00:00:00.021538417
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.6263155222235377]
└ * Angles: [0]
[ Info: Final F: 1.216140605153019
[ Info: Final loss: 8.060993367930467e-7
[ Info: Final stress: 2.3505801695610388e-8
[ Info: Total solve! calls: 27
[ Info: Total SCFT iterations: 270
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.6263155222235377]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 9.173627260872319e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.2690935429
[ Info: final loss: 9.17e-7
[ Info: final stress norm: 5.28e-9
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.5191074541101033]
└ * Angles: [0]
[ Info: iterations: 550
[ Info: time per iteration: 440 microseconds, 246 nanoseconds
[ Info: Run time: 00:00:00.242135667
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.5191074541101033]
└ * Angles: [0]
[ Info: Final F: 1.269093542940276
[ Info: Final loss: 9.173627260872319e-7
[ Info: Final stress: 5.283438332023666e-9
[ Info: Total solve! calls: 55
[ Info: Total SCFT iterations: 550
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.5191074541101033]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: number: 100
[ Info: F: 1.3242184592
[ Info: resediual norm: 0.000394
[ Info: stress norm: 2.64e-10
[ Info: cell: [3.4088]
[ Info: number: 200
[ Info: F: 1.3242159065
[ Info: resediual norm: 5.73e-5
[ Info: stress norm: 8.14e-12
[ Info: cell: [3.40874]
[ Info: number: 300
[ Info: F: 1.3242158534
[ Info: resediual norm: 8.36e-6
[ Info: stress norm: 2.25e-13
[ Info: cell: [3.40874]
[ Info: number: 400
[ Info: F: 1.3242158523
[ Info: resediual norm: 1.22e-6
[ Info: stress norm: 4.82e-15
[ Info: cell: [3.40874]
[ Info: final loss: 9.88150980728329e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.3242158523
[ Info: final loss: 9.88e-7
[ Info: final stress norm: 3.16e-15
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.4087397638821413]
└ * Angles: [0]
[ Info: iterations: 4110
[ Info: time per iteration: 92 microseconds, 520 nanoseconds
[ Info: Run time: 00:00:00.380258125
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.4087397638821413]
└ * Angles: [0]
[ Info: Final F: 1.32421585228201
[ Info: Final loss: 9.88150980728329e-7
[ Info: Final stress: 3.155329510700846e-15
[ Info: Total solve! calls: 411
[ Info: Total SCFT iterations: 4110
[ Info: Total time: 00:00:01
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: 1S semi-implicit method (SIS-1) with α=1.0.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.4087397638821413]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 9.15586208483552e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.3867508867
[ Info: final loss: 9.16e-7
[ Info: final stress norm: 2.23e-12
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.4087397638821413]
└ * Angles: [0]
[ Info: iterations: 130
[ Info: time per iteration: 72 microseconds, 429 nanoseconds
[ Info: Run time: 00:00:00.009415834
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.4087397638821413]
└ * Angles: [0]
[ Info: Final F: 1.386750886724393
[ Info: Final loss: 9.15586208483552e-7
[ Info: Final stress: 2.2311562788070764e-12
[ Info: Total solve! calls: 13
[ Info: Total SCFT iterations: 130
[ Info: Total time: 00:00:01Visualize the free energy curves of LAM and DIS phase.
begin
ϕAs_AB_A_dis = 0.01:0.01:0.99
ϕABs_AB_A_dis = 1 .- ϕAs_AB_A_dis
Fs_AB_A_dis = similar(ϕAs_AB_A_dis)
μs_AB_A_dis = similar(ϕAs_AB_A_dis)
for i in eachindex(ϕAs_AB_A_dis)
system = Polymer.update!(system_lam, ϕAs_AB_A_dis[i], ϕA_AB_A_control)
Fs_AB_A_dis[i], μs_AB_A_dis[i] = Polyorder.F_DIS(system), Polyorder.μ̃_DIS(system, 1)
end
endlet
f = Figure()
ax = Axis(f[1, 1],
xlabel = L"$\phi_{AB}$",
ylabel = L"$F$",
)
lines!(ax, ϕABs_AB_A_lam, Fs_AB_A_lam, label="LAM")
scatter!(ax, ϕABs_AB_A_lam, Fs_AB_A_lam, label=nothing; markersize=2)
lines!(ax, ϕABs_AB_A_dis[1:end], Fs_AB_A_dis[1:end], label="DIS")
f
end┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.
└ @ Makie ~/.julia/packages/Makie/PpRC2/src/scenes.jl:264The same straight line is subtracted from both the free energy curves of the LAM and DIS phases. It can be seen that
- when $\phi_A < 0.06$ ($\phi_{AB}>0.94$), LAM reduces to DIS. Thus in this region, the stable phase is DIS.
- A cotangent line can be constructed by connecting $\phi_{A} \approx 0.25$ ($\phi_{AB} \approx 0.75$) and $\phi_{A} \approx 0.93$ ($\phi_{AB} \approx 0.07$). Thus in this region, LAM and DIS coexist.
- When $0.06 < \phi_{A} < 0.25$ ($0.75 < \phi_{AB} < 0.94$), LAM is the stable phase.
- When $\phi_{A} > 0.93$ ($\phi_{AB} < 0.07$), DIS is the stable phase again.
These observations are consistent with the result presented in Fig. 3 of Ref. Mester, Z.; Lynd, N. A.; Fredrickson, G. H. Numerical Self-Consistent Field Theory of Multicomponent Polymer Blends in the Gibbs Ensemble. Soft Matter 2013, 9 (47), 11288.
let
f = Figure()
ax = Axis(f[1, 1],
xlabel = L"$\phi_{AB}$",
ylabel = L"$F$",
)
line = get_line(ϕABs_AB_A_dis[1], Fs_AB_A_dis[1], ϕABs_AB_A_dis[end], Fs_AB_A_dis[end])
F_lam = subtract_line(line, ϕABs_AB_A_lam, Fs_AB_A_lam)
lines!(ax, ϕABs_AB_A_lam, F_lam, label="LAM")
scatter!(ax, ϕABs_AB_A_lam, F_lam, label=nothing)
F_dis = subtract_line(line, ϕABs_AB_A_dis, Fs_AB_A_dis)
lines!(ax, ϕABs_AB_A_dis, F_dis, label="DIS")
f
end┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.
└ @ Makie ~/.julia/packages/Makie/PpRC2/src/scenes.jl:264RootsOptimizer
RootsOptimizer is less robust than other optimizers. You have to make sure that the data range should not include any inflection point in the free energy curve.
The other important thing to bare in mind is that the chemical potential returned is for the first component in the polymer system, which is AB block copolymer in our AB_A_system(). Therefore, we have to use $\phi_{AB}$ as the independent variable.
The coexistence point in ϕAB is 0.0670242 and 0.751779 as computed.
let
# ϕAB range for DIS phase is [0.02, 0.2]
s1 = CHSplineSurrogate(reverse(ϕABs_AB_A_dis)[2:20] |> collect, reverse(Fs_AB_A_dis)[2:20] |> collect, reverse(μs_AB_A_dis)[2:20] |> collect)
# ϕAB range for LAM phase is [0.7, 0.98]
s2 = CHSplineSurrogate(ϕABs_AB_A_lam[3:end] |> collect, Fs_AB_A_lam[3:end] |> collect, μs_AB_A_lam[3:end] |> collect)
smp = SurrogateMacrophaseModel(s1, s2, ϕA_AB_A_control; ϕ₁=0.1, ϕ₂=0.8, ϕ₀=0.6)
# macrophase(JSOOptimizer(), smp; lb=[0.02, 0.7], ub=[0.2, 0.9]) # also works.
# macrophase(OptimOptimizer(), smp; lb=[0.02, 0.7], ub=[0.2, 0.9]) # also works
# RootsOptimizer's bound depends on the input surrogates, cannot be set separately.
macrophase(RootsOptimizer(), smp)
end(0.06703239288354801, 0.7527251272714819, nothing)OPSOptimizer
Internal optimizer is used for computing the coexistence based on surrogates. The most robust internal optimizer is the OptimOptimizer. For this particular case, JSOOptimizer fails.
The coexistence point in ϕAB is 0.0.0670345 and 0.752099 as computed.
let
ds = 0.01
uc = UnitCell(5.0)
lat = BravaisLattice(uc)
system = AB_A_system(; χN=10.0, ϕAB=0.7, fA=0.45, α=1.0)
ϕAB_control = ϕControlParameter(:AB, system)
scft_dis = NoncyclicChainSCFT(system, lat, 0.1)
scft = NoncyclicChainSCFT(system, lat, ds)
Polyorder.solve!(scft)
updater = VariableCell(BB(1.0), SIS(1.0))
scft_lam = NoncyclicChainSCFT(system, lat, ds; updater)
Polyorder.initialize!(scft_lam, scft.wfields)
model_dis = PolyorderModel(scft_dis)
model_lam = PolyorderModel(scft_lam)
# All ϕs are for AB diblock copolymer
ϕdis_init = [0.02, 0.2]
# ϕlam_init = [0.6, 0.8] # [0.6, 0.8] works for OptimOptimizer and RootsOptimizer
ϕlam_init = [0.7, 0.9]
tol_io = 1e-8
tol_oo = 1e-4
ϕ1, ϕ2, ϕ0 = 0.1, 0.8, 0.6
m = MacrophaseModel(model_dis, model_lam, ϕAB_control;
phase1=DISPhase, phase2=LAMPhase,
ϕ₁=ϕ1, ϕ₂=ϕ2, ϕ₀=ϕ0, cached=true)
# io = RootsOptimizer(x_abstol=tol_io)
io = OptimOptimizer(x_abstol=tol_io)
oo = OPSOptimizer(ϕdis_init, ϕlam_init; optimizer=io, x_abstol=tol_oo)
ϕ₁, ϕ₂, _ = macrophase(oo, m)
end[ Info: ******* SCFT Simulation Start *******
[ Info: Algorithm: PicardMann iteration with α=0.2.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.0]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: number: 100
[ Info: F: 0.6673584304
[ Info: resediual norm: 0.00213
[ Info: number: 200
[ Info: F: 0.6673898126
[ Info: resediual norm: 0.000322
[ Info: number: 300
[ Info: F: 0.6673803223
[ Info: resediual norm: 9.57e-5
[ Info: number: 400
[ Info: F: 0.667379361
[ Info: resediual norm: 2.95e-5
[ Info: number: 500
[ Info: F: 0.6673792562
[ Info: resediual norm: 9.6e-6
[ Info: number: 600
[ Info: F: 0.6673792441
[ Info: resediual norm: 3.18e-6
[ Info: number: 700
[ Info: F: 0.6673792427
[ Info: resediual norm: 1.06e-6
[ Info: final loss: 9.94933958466398e-7
[ Info: Stop triggered by EarlyStopping.Threshold(1.0e-6) stopping criterion.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.6673792427
[ Info: final loss: 9.95e-7
[ Info: final stress norm: 0.0019443753562810862
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.0]
└ * Angles: [0]
[ Info: iterations: 706
[ Info: time per iteration: 108 microseconds, 708 nanoseconds
[ Info: Run time: 00:00:00.076748
[ Info: =======================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.02 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.2 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.7 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
┌ Warning: Timed out waiting for `Base.active_repl_backend.ast_transforms` to become available. Autoloads will not work.
└ @ BasicAutoloads ~/.julia/packages/BasicAutoloads/08hIo/src/BasicAutoloads.jl:117
[ Info: If you have a slow startup file, consider moving `register_autoloads` to the end of it.
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [5.0]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 9.489873107824222e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.6673105692
[ Info: final loss: 9.49e-7
[ Info: final stress norm: 6.26e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929813126246492]
└ * Angles: [0]
[ Info: iterations: 110
[ Info: time per iteration: 7 milliseconds, 707 microseconds, 652 nanoseconds
[ Info: Run time: 00:00:00.847841791
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929813126246492]
└ * Angles: [0]
[ Info: Final F: 0.667310569244048
[ Info: Final loss: 9.489873107824222e-7
[ Info: Final stress: 6.261105775724781e-8
[ Info: Total solve! calls: 11
[ Info: Total SCFT iterations: 110
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.9 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929813126246492]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.022386025172836e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 1.1643950602
[ Info: final loss: 8.02e-7
[ Info: final stress norm: 2.02e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.7302686839920463]
└ * Angles: [0]
[ Info: iterations: 380
[ Info: time per iteration: 74 microseconds, 826 nanoseconds
[ Info: Run time: 00:00:00.028434208
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [3.7302686839920463]
└ * Angles: [0]
[ Info: Final F: 1.1643950601764115
[ Info: Final loss: 8.022386025172836e-7
[ Info: Final stress: 2.0153536631018778e-8
[ Info: Total solve! calls: 38
[ Info: Total SCFT iterations: 380
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.077986 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.799925 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.929813126246492]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.631423743886505e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.9133651077
[ Info: final loss: 8.63e-7
[ Info: final stress norm: 2.11e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.2643441034604335]
└ * Angles: [0]
[ Info: iterations: 230
[ Info: time per iteration: 84 microseconds, 108 nanoseconds
[ Info: Run time: 00:00:00.019344875
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.2643441034604335]
└ * Angles: [0]
[ Info: Final F: 0.9133651076678013
[ Info: Final loss: 8.631423743886505e-7
[ Info: Final stress: 2.1085240332141832e-8
[ Info: Total solve! calls: 23
[ Info: Total SCFT iterations: 230
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.063789 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.754828 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.2643441034604335]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 8.688642019882246e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.8020999422
[ Info: final loss: 8.69e-7
[ Info: final stress norm: 7.55e-9
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.540241647935044]
└ * Angles: [0]
[ Info: iterations: 180
[ Info: time per iteration: 84 microseconds, 258 nanoseconds
[ Info: Run time: 00:00:00.015166458
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.540241647935044]
└ * Angles: [0]
[ Info: Final F: 0.8020999421659334
[ Info: Final loss: 8.688642019882246e-7
[ Info: Final stress: 7.554323257942448e-9
[ Info: Total solve! calls: 18
[ Info: Total SCFT iterations: 180
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.067057 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.751812 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.540241647935044]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 6.998750488834815e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.7946750378
[ Info: final loss: 7.0e-7
[ Info: final stress norm: 3.12e-8
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.5599649161212605]
└ * Angles: [0]
[ Info: iterations: 110
[ Info: time per iteration: 80 microseconds, 674 nanoseconds
[ Info: Run time: 00:00:00.008874208
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.5599649161212605]
└ * Angles: [0]
[ Info: Final F: 0.7946750377906326
[ Info: Final loss: 6.998750488834815e-7
[ Info: Final stress: 3.116529035851736e-8
[ Info: Total solve! calls: 11
[ Info: Total SCFT iterations: 110
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.067042 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.751693 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.5599649161212605]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 7.952866312182435e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.7943829015
[ Info: final loss: 7.95e-7
[ Info: final stress norm: 5.83e-7
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.560725056792581]
└ * Angles: [0]
[ Info: iterations: 50
[ Info: time per iteration: 574 microseconds, 555 nanoseconds
[ Info: Run time: 00:00:00.028727792
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.560725056792581]
└ * Angles: [0]
[ Info: Final F: 0.7943829014723307
[ Info: Final loss: 7.952866312182435e-7
[ Info: Final stress: 5.832922876482787e-7
[ Info: Total solve! calls: 5
[ Info: Total SCFT iterations: 50
[ Info: Total time: 00:00:01
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.067042 phase: DIS
[ Info:
[ Info: ======================================================
[ Info: ======================================================
[ Info:
[ Info: ϕ = 0.751693 phase: LAM
[ Info:
[ Info: ======================================================
[ Info: ###### Cell Optimization Start ######
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: Cell optimization starts ...
[ Info: ******* SCFT Simulation Start *******
┌ Info: Algorithm: Variable cell method
│ * Cell updater: Barzilai-Borwein (BB2) method
│ * max step size: 1.0
│ * step size: 0.2.
│ * Fields updater: PicardMann iteration with α=0.2.
└ * Scheme: run fields updater 10 times per cell iteration.
[ Info: MDE solvers: ["OSF"]
[ Info: tolerance: 1.0e-5 (stress norm)
[ Info: tolerance: 1.0e-6 (Residual)
[ Info: initial F: Inf
[ Info: initial residual norm: 0.0
[ Info: initial stress norm: NaN
┌ Info: initial unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.560725056792581]
└ * Angles: [0]
[ Info:
[ Info: Simulation starts > > > > > >
[ Info: final loss: 2.317180184347666e-7
[ Info: Stop triggered by a `ThresholdStress` control.
[ Info: > > > > > > Simulation finished.
[ Info:
[ Info: ------ SCFT Simulation Summary ------
[ Info: convergence: Polyorder.Successful()
[ Info: final F: 0.7943833434
[ Info: final loss: 2.32e-7
[ Info: final stress norm: 6.47e-7
┌ Info: final unit cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.560725186436381]
└ * Angles: [0]
[ Info: iterations: 20
[ Info: time per iteration: 84 microseconds, 489 nanoseconds
[ Info: Run time: 00:00:00.001689791
[ Info: =======================================
[ Info: Cell optimization finished.
[ Info: ------ Cell Optimization Summary ------
[ Info: Convergence: Polyorder.Successful()
┌ Info: Stress-free cell: UnitCell
│ * Crystal system: Line
│ * Edges: [4.560725186436381]
└ * Angles: [0]
[ Info: Final F: 0.7943833434464063
[ Info: Final loss: 2.317180184347666e-7
[ Info: Final stress: 6.468070334560042e-7
[ Info: Total solve! calls: 2
[ Info: Total SCFT iterations: 20
[ Info: Total time: 00:00:01
(0.06704172117731037, 0.7516931569494402, (10, [0.02, 0.2, 0.07798583826477423, 0.06378889438017175, 0.06705655939772899, 0.06704175426434512, 0.06704172117731037], [0.7, 0.9, 0.7999245104511178, 0.7548281267521397, 0.7518116984787448, 0.7516931270371734, 0.7516931569494402], [-0.989249113279732, -0.5214024235381877, -0.8632976230451874, -0.8987378390466816, -0.8907488410504592, -0.8907852827924947, -0.8907853642313469], [0.667310569244048, 1.1643950601764115, 0.9133651076678013, 0.8020999421659334, 0.7946750377906326, 0.7943829014723307, 0.7943833434464063]))Exercises
- Reproduce the whole Fig.3 of Ref. Mester, Z.; Lynd, N. A.; Fredrickson, G. H. Numerical Self-Consistent Field Theory of Multicomponent Polymer Blends in the Gibbs Ensemble. Soft Matter 2013, 9 (47), 11288.