@@ -8,6 +8,18 @@ cdef class _SolutionBase:
88 source = None , yaml = None , thermo = None , species = (),
99 kinetics = None , reactions = (), **kwargs ):
1010
11+ # run instantiation only if valid sources are specified
12+ if origin or infile or source or (thermo and species):
13+
14+ self ._cinit(infile = infile, name = name, adjacent = adjacent,
15+ origin = origin, source = source, yaml = yaml,
16+ thermo = thermo, species = species, kinetics = kinetics,
17+ reactions = reactions, ** kwargs)
18+
19+ def _cinit (self , infile = ' ' , name = ' ' , adjacent = (), origin = None ,
20+ source = None , yaml = None , thermo = None , species = (),
21+ kinetics = None , reactions = (), **kwargs ):
22+
1123 if ' phaseid' in kwargs:
1224 if name is not ' ' :
1325 raise AttributeError (' duplicate specification of phase name' )
@@ -67,6 +79,7 @@ cdef class _SolutionBase:
6779 self ._selected_species = np.ndarray(0 , dtype = np.integer)
6880
6981 def __init__ (self , *args , **kwargs ):
82+
7083 if isinstance (self , Transport):
7184 assert self .transport is not NULL
7285
@@ -225,8 +238,15 @@ cdef class _SolutionBase:
225238 for i,spec in enumerate (species):
226239 self ._selected_species[i] = self .species_index(spec)
227240
228- def __reduce__ (self ):
229- raise NotImplementedError (' Solution object is not picklable' )
241+ def __getstate__ (self ):
242+ """ Save complete information for pickling."""
243+ return self .xml_string, self .ID, self .state
244+
245+ def __setstate__ (self , pkl ):
246+ """ Restore Solution from pickled information."""
247+ xml, phaseid, state = pkl
248+ self ._cinit(source = xml, phaseid = phaseid)
249+ self .state = state
230250
231251 def __copy__ (self ):
232252 raise NotImplementedError (' Solution object is not copyable' )
0 commit comments