Skip to content

Commit 2347311

Browse files
committed
use vectorized calculators in domain calcthermo functions
1 parent 2b8decd commit 2347311

1 file changed

Lines changed: 21 additions & 36 deletions

File tree

src/Domain.jl

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,10 @@ end
658658
Gs = zeros(length(d.phase.species))
659659
Us = zeros(length(d.phase.species))
660660
Cvave = 0.0
661-
@simd for i = 1:length(d.phase.species)
662-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
663-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
664-
@fastmath @inbounds Us[i] = (hdivRT-1.0)*R*T
665-
@fastmath @inbounds Cvave += cpdivR*ns[i]
666-
end
661+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
662+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
663+
@fastmath Us = (hdivRT.-1.0)*(R*T)
664+
@fastmath Cvave = dot(cpdivR,ns)
667665
@fastmath Cvave *= R/N
668666
@fastmath Cvave -= R
669667
if d.phase.diffusionlimited
@@ -688,13 +686,10 @@ end
688686
C = N/V
689687
Gs = zeros(length(d.phase.species))
690688
Hs = zeros(length(d.phase.species))
691-
Cvave = 0.0
692-
@simd for i = 1:length(d.phase.species)
693-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
694-
@fastmath @inbounds Hs[i] = hdivRT*R*T
695-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
696-
@fastmath @inbounds Cvave += cpdivR*ns[i]
697-
end
689+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
690+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
691+
@fastmath Hs = hdivRT.*(R*T)
692+
@fastmath Cvave = dot(cpdivR,ns)
698693
@fastmath Cvave *= R/N
699694
@fastmath Cvave -= R
700695
if d.phase.diffusionlimited
@@ -720,13 +715,10 @@ end
720715
P = C*R*T
721716
Gs = zeros(length(d.phase.species))
722717
Us = zeros(length(d.phase.species))
723-
Cvave = 0.0
724-
@simd for i = 1:length(d.phase.species)
725-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
726-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
727-
@fastmath @inbounds Us[i] = (hdivRT-1.0)*R*T
728-
@fastmath @inbounds Cvave += cpdivR*ns[i]
729-
end
718+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
719+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
720+
@fastmath Us = (hdivRT.-1.0)*(R*T)
721+
@fastmath Cvave = dot(cpdivR,ns)
730722
@fastmath Cvave *= R/N
731723
@fastmath Cvave -= R
732724
if d.phase.diffusionlimited
@@ -752,13 +744,10 @@ end
752744
C = N/V
753745
Gs = zeros(length(d.phase.species))
754746
Hs = zeros(length(d.phase.species))
755-
Cvave = 0.0
756-
@simd for i = 1:length(d.phase.species)
757-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
758-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
759-
@fastmath @inbounds Hs[i] = hdivRT*R*T
760-
@fastmath @inbounds Cvave += cpdivR*ns[i]
761-
end
747+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
748+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
749+
@fastmath Hs = hdivRT.*(R*T)
750+
@fastmath Cvave = dot(cpdivR,ns)
762751
@fastmath Cvave *= R/N
763752
@fastmath Cvave -= R
764753
if d.phase.diffusionlimited
@@ -784,10 +773,8 @@ end
784773
P = C*R*T
785774
Gs = zeros(length(d.phase.species))
786775
mu = d.phase.solvent.mu(T)
787-
for i = 1:length(d.phase.species)
788-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
789-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
790-
end
776+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
777+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
791778
if d.phase.diffusionlimited
792779
diffs = [x(T=T,mu=mu,P=P) for x in getfield.(d.phase.species,:diffusion)]
793780
else
@@ -813,11 +800,9 @@ end
813800
P = C*R*T
814801
Gs = zeros(length(d.phase.species))
815802
Us = zeros(length(d.phase.species))
816-
Cvave = 0.0
817-
@simd for i = 1:length(d.phase.species)
818-
@inbounds cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.species[i].thermo,T)
819-
@fastmath @inbounds Gs[i] = (hdivRT-sdivR)*R*T
820-
end
803+
cpdivR,hdivRT,sdivR = calcHSCpdless(d.phase.vecthermo,T)
804+
@fastmath Gs = (hdivRT.-sdivR)*(R*T)
805+
@fastmath Cvave = dot(cpdivR,ns)
821806
@fastmath Cvave *= R/N
822807
@fastmath Cvave -= R
823808
if d.phase.diffusionlimited

0 commit comments

Comments
 (0)