Skip to content

Commit d8c26c0

Browse files
committed
Merge main and drop .DS_Store
2 parents 014d1c2 + e293520 commit d8c26c0

File tree

4 files changed

+45
-19
lines changed

4 files changed

+45
-19
lines changed

DISCLAIMER

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Disclaimer
2+
3+
This material was prepared as an account of work sponsored by an agency of the United States Government.  Neither the United States Government nor the United States Department of Energy, nor the Contractor, nor any or their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights.
4+
Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.
5+
PACIFIC NORTHWEST NATIONAL LABORATORY
6+
operated by
7+
BATTELLE
8+
for the
9+
UNITED STATES DEPARTMENT OF ENERGY
10+
under Contract DE-AC05-76RL01830

src/part2pop.egg-info/SOURCES.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ src/part2pop/analysis/population/factory/s_grid.py
143143
src/part2pop/analysis/population/factory/spec_mass_conc.py
144144
src/part2pop/analysis/population/factory/wvl_grid.py
145145
src/part2pop/data/__init__.py
146-
src/part2pop/data/__pycache__/__init__.cpython-311.pyc
147-
src/part2pop/data/__pycache__/__init__.cpython-312.pyc
148146
src/part2pop/data/species_data/aero_data.dat
149147
src/part2pop/data/species_data/freezing_data.dat
150148
src/part2pop/data/species_data/ri_water.csv

src/part2pop/aerosol_particle.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _equilibrate_h2o(
4949
RH=maxRH
5050

5151
Ddry = self.get_Ddry()
52-
Dwet = compute_Dwet(Ddry, self.get_tkappa(), RH, T,
52+
Dwet = compute_Dwet(Ddry, self.get_tkappa(), RH, T,
5353
sigma_h2o=sigma_h2o, rho_h2o=rho_h2o, MW_h2o=MW_h2o)
5454
mass_h2o = compute_mass_h2o(Ddry,Dwet,rho_h2o=1000.)
5555
self.masses[self.idx_h2o()] = mass_h2o
@@ -65,14 +65,20 @@ def get_variable(self, varname, *kwargs):
6565
*kwargs : tuple
6666
Additional arguments forwarded to the underlying method.
6767
"""
68-
if varname == 'wet_diameter':
68+
if varname == 'wet_diameter' or varname == 'Dwet':
6969
return self.get_Dwet(*kwargs)
70-
elif varname == 'dry_diameter':
70+
elif varname == 'dry_diameter' or varname == 'Ddry':
7171
return self.get_Ddry()
7272
elif varname == 'tkappa':
7373
return self.get_tkappa()
7474
elif varname == 'critical_supersaturation' or varname == 's_c':
7575
return self.get_critical_supersaturation(T, return_D_crit=False, sigma_h2o=0.072)
76+
elif varname == 'vol_tot':
77+
return self.get_vol_tot()
78+
elif varname == 'vol_dry':
79+
return self.get_vol_dry()
80+
elif varname == 'concentrations':
81+
return self.get_species_concs()
7682

7783
def idx_h2o(self):
7884
return np.where([
@@ -81,13 +87,11 @@ def idx_h2o(self):
8187
def idx_dry(self):
8288
idx_all = np.arange(len(self.species))
8389
idx_h2o = self.idx_h2o()
84-
90+
spec_densities = self.get_spec_rhos()
8591
if idx_h2o == -1:
86-
idx_not_h2o = idx_all[:-1]
87-
elif idx_h2o >= 0:
88-
idx_not_h2o = np.hstack([idx for idx in idx_all if idx != idx_h2o])
89-
else:
90-
idx_not_h2o = np.hstack([idx_all[:idx_h2o],idx_all[idx_h2o:][1:]])
92+
idx_not_h2o = np.hstack([idx for idx in idx_all[:-1] if idx != idx_h2o and spec_densities[idx]>0])
93+
else:
94+
idx_not_h2o = np.hstack([idx for idx in idx_all if idx != idx_h2o and spec_densities[idx]>0])
9195
return idx_not_h2o
9296

9397
def idx_core(self,core_specs=['BC']):
@@ -177,14 +181,14 @@ def get_vks(self):
177181

178182
def get_vol_tot(self):
179183
vks = self.get_vks()
180-
vol_tot = np.sum(vks)
184+
vol_tot = np.nansum(vks[self.idx_dry()]) + vks[self.idx_h2o()]
181185
return vol_tot
182186

183187
def get_vol_dry(self):
184188
vks = self.get_vks()
185189
vol_dry = np.sum(vks[self.idx_dry()])
186190
return vol_dry
187-
191+
188192
def get_vol_core(self):
189193
vks = self.get_vks()
190194
vol_core = np.sum(vks[self.idx_core()])
@@ -243,8 +247,7 @@ def get_tkappa(self):
243247
# compute effective kappa
244248
vks = self.get_vks()
245249
spec_kappas = self.get_spec_kappas()
246-
idx_not_h2o, = np.where([one_spec.name.upper()!='H2O' for one_spec in self.species])
247-
tkappa = np.sum(vks[idx_not_h2o]*spec_kappas[idx_not_h2o])/np.sum(vks[idx_not_h2o])
250+
tkappa = np.sum(vks[self.idx_dry()]*spec_kappas[self.idx_dry()])/np.sum(vks[self.idx_dry()])
248251
return tkappa
249252

250253
def get_shell_tkappa(self):
@@ -301,6 +304,12 @@ def get_critical_supersaturation(self, T, return_D_crit=False):
301304
return s_critical,D_critical
302305
else:
303306
return s_critical
307+
308+
def get_species_concs(self):
309+
water_volume = np.repeat(self.get_vol_tot() - self.get_vol_dry(), len(self.masses))
310+
molec_masses = np.array([species.molar_mass for species in self.species])
311+
concs = (self.masses/molec_masses)/water_volume
312+
return concs
304313

305314

306315
# def make_particle(

src/part2pop/population/base.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ def add_particle(self, particle, part_id, num_conc):
6464
self.ids.append(part_id)
6565

6666
def get_species_idx(self, spec_name):
67-
idx, = np.where([
68-
spec.name in spec_name for spec in self.species])
69-
return idx[0]
67+
names = [spec.name for spec in self.species]
68+
try:
69+
return np.where(np.array(names) == spec_name)[0][0]
70+
except:
71+
return None
7072

7173
def _equilibrate_h2o(self,S,T,rho_h2o=1000., MW_h2o=18e-3):
7274
for (part_id,num_conc) in zip(self.ids,self.num_concs):
@@ -145,4 +147,11 @@ def reduce_mixing_state(self, mixing_state='part_res',
145147
mass_h2o = vol_h2o*rho_h2o
146148
particle.spec_masses[particle.idx_h2o()] = mass_h2o
147149
num_conc =self.num_conc[ii]
148-
self.set_particle(particle, part_id, num_conc, suppress_warning=False)
150+
self.set_particle(particle, part_id, num_conc, suppress_warning=False)
151+
152+
def clone_detached(self):
153+
"""Return a copy that shares immutable data but has detached numeric arrays."""
154+
return ParticlePopulation(
155+
species=self.species, spec_masses=self.spec_masses.copy(),
156+
num_concs=self.num_concs.copy(), ids=self.ids
157+
)

0 commit comments

Comments
 (0)