@@ -110,164 +110,143 @@ impl fmt::Display for PyHelmholtzEnergy {
110110}
111111
112112macro_rules! state {
113- ( $py_state_id: ident, $py_state_ty : ty , $py_hd_ty : ty , $hd_ty: ty) => {
113+ ( $py_state_id: ident, $py_hd_id : ident , $hd_ty: ty) => {
114114 #[ pyclass]
115115 #[ derive( Clone ) ]
116116 struct $py_state_id( StateHD <$hd_ty>) ;
117117
118- impl From <StateHD <$hd_ty>> for $py_state_ty {
118+ impl From <StateHD <$hd_ty>> for $py_state_id {
119119 fn from( s: StateHD <$hd_ty>) -> Self {
120120 Self ( s)
121121 }
122122 }
123123
124124 #[ pymethods]
125- impl $py_state_ty {
125+ impl $py_state_id {
126126 #[ new]
127- pub fn new( temperature: $py_hd_ty , volume: $py_hd_ty , moles: Vec <$py_hd_ty >) -> Self {
127+ pub fn new( temperature: $py_hd_id , volume: $py_hd_id , moles: Vec <$py_hd_id >) -> Self {
128128 let m = Array1 :: from( moles) . mapv( <$hd_ty>:: from) ;
129129 Self ( StateHD :: <$hd_ty>:: new( temperature. into( ) , volume. into( ) , m) )
130130 }
131131
132132 #[ getter]
133- pub fn get_temperature( & self ) -> $py_hd_ty {
134- <$py_hd_ty >:: from( self . 0 . temperature)
133+ pub fn get_temperature( & self ) -> $py_hd_id {
134+ <$py_hd_id >:: from( self . 0 . temperature)
135135 }
136136
137137 #[ getter]
138- pub fn get_volume( & self ) -> $py_hd_ty {
139- <$py_hd_ty >:: from( self . 0 . volume)
138+ pub fn get_volume( & self ) -> $py_hd_id {
139+ <$py_hd_id >:: from( self . 0 . volume)
140140 }
141141
142142 #[ getter]
143- pub fn get_moles( & self ) -> Vec <$py_hd_ty > {
144- self . 0 . moles. mapv( <$py_hd_ty >:: from) . into_raw_vec( )
143+ pub fn get_moles( & self ) -> Vec <$py_hd_id > {
144+ self . 0 . moles. mapv( <$py_hd_id >:: from) . into_raw_vec( )
145145 }
146146
147147 #[ getter]
148- pub fn get_partial_density( & self ) -> Vec <$py_hd_ty > {
148+ pub fn get_partial_density( & self ) -> Vec <$py_hd_id > {
149149 self . 0
150150 . partial_density
151- . mapv( <$py_hd_ty >:: from)
151+ . mapv( <$py_hd_id >:: from)
152152 . into_raw_vec( )
153153 }
154154
155155 #[ getter]
156- pub fn get_molefracs( & self ) -> Vec <$py_hd_ty > {
157- self . 0 . molefracs. mapv( <$py_hd_ty >:: from) . into_raw_vec( )
156+ pub fn get_molefracs( & self ) -> Vec <$py_hd_id > {
157+ self . 0 . molefracs. mapv( <$py_hd_id >:: from) . into_raw_vec( )
158158 }
159159
160160 #[ getter]
161- pub fn get_density( & self ) -> $py_hd_ty {
162- <$py_hd_ty >:: from( self . 0 . partial_density. sum( ) )
161+ pub fn get_density( & self ) -> $py_hd_id {
162+ <$py_hd_id >:: from( self . 0 . partial_density. sum( ) )
163163 }
164164 }
165165 } ;
166166}
167167
168168macro_rules! dual_number {
169- ( $py_hd_id: ident, $py_hd_ty : ty , $ hd_ty: ty, $py_field_ty: ty) => {
169+ ( $py_hd_id: ident, $hd_ty: ty, $py_field_ty: ty) => {
170170 #[ pyclass]
171171 #[ derive( Clone ) ]
172172 struct $py_hd_id( $hd_ty) ;
173- impl_dual_num!( $py_hd_ty , $hd_ty, $py_field_ty) ;
173+ impl_dual_num!( $py_hd_id , $hd_ty, $py_field_ty) ;
174174 } ;
175175}
176176
177177macro_rules! helmholtz_energy {
178- ( $py_state_ty : ty , $py_hd_ty : ty , $hd_ty: ty) => {
178+ ( $py_state_id : ident , $py_hd_id : ident , $hd_ty: ty) => {
179179 impl HelmholtzEnergyDual <$hd_ty> for PyHelmholtzEnergy {
180180 fn helmholtz_energy( & self , state: & StateHD <$hd_ty>) -> $hd_ty {
181181 Python :: with_gil( |py| {
182182 let py_result = self
183183 . 0
184184 . as_ref( py)
185- . call_method1( "helmholtz_energy" , ( <$py_state_ty >:: from( state. clone( ) ) , ) )
185+ . call_method1( "helmholtz_energy" , ( <$py_state_id >:: from( state. clone( ) ) , ) )
186186 . unwrap( ) ;
187- <$hd_ty>:: from( py_result. extract:: <$py_hd_ty >( ) . unwrap( ) )
187+ <$hd_ty>:: from( py_result. extract:: <$py_hd_id >( ) . unwrap( ) )
188188 } )
189189 }
190190 }
191191 } ;
192192}
193193
194194macro_rules! impl_dual_state_helmholtz_energy {
195- ( $py_state_id: ident, $py_state_ty : ty , $ py_hd_id: ident, $py_hd_ty : ty , $hd_ty: ty, $py_field_ty: ty) => {
196- dual_number!( $py_hd_id, $py_hd_ty , $ hd_ty, $py_field_ty) ;
197- state!( $py_state_id, $py_state_ty , $py_hd_ty , $hd_ty) ;
198- helmholtz_energy!( $py_state_ty , $py_hd_ty , $hd_ty) ;
195+ ( $py_state_id: ident, $py_hd_id: ident, $hd_ty: ty, $py_field_ty: ty) => {
196+ dual_number!( $py_hd_id, $hd_ty, $py_field_ty) ;
197+ state!( $py_state_id, $py_hd_id , $hd_ty) ;
198+ helmholtz_energy!( $py_state_id , $py_hd_id , $hd_ty) ;
199199 } ;
200200}
201201
202202// No definition of dual number necessary for f64
203- state ! ( PyStateF , PyStateF , f64 , f64 ) ;
203+ state ! ( PyStateF , f64 , f64 ) ;
204204helmholtz_energy ! ( PyStateF , f64 , f64 ) ;
205205
206- // Arguments:
207- // - python state identifier,
208- // - python state type (=identifier),
209- // - python dual number identifier,
210- // - python dual number type (=identifier),
211- // - rust dual number type,
212- // - python dual number field type (return of re(), etc.)
213- impl_dual_state_helmholtz_energy ! ( PyStateD , PyStateD , PyDual64 , PyDual64 , Dual64 , f64 ) ;
214- dual_number ! ( PyDualVec3 , PyDualVec3 , DualVec64 <3 >, f64 ) ;
206+ impl_dual_state_helmholtz_energy ! ( PyStateD , PyDual64 , Dual64 , f64 ) ;
207+ dual_number ! ( PyDualVec3 , DualVec64 <3 >, f64 ) ;
215208impl_dual_state_helmholtz_energy ! (
216209 PyStateDualDualVec3 ,
217- PyStateDualDualVec3 ,
218- PyDualDualVec3 ,
219210 PyDualDualVec3 ,
220211 Dual <DualVec64 <3 >, f64 >,
221212 PyDualVec3
222213) ;
223214impl_dual_state_helmholtz_energy ! (
224215 PyStateHD ,
225- PyStateHD ,
226- PyHyperDual64 ,
227216 PyHyperDual64 ,
228217 HyperDual64 ,
229218 f64
230219) ;
231- impl_dual_state_helmholtz_energy ! ( PyStateD2 , PyStateD2 , PyDual2_64 , PyDual2_64 , Dual2_64 , f64 ) ;
232- impl_dual_state_helmholtz_energy ! ( PyStateD3 , PyStateD3 , PyDual3_64 , PyDual3_64 , Dual3_64 , f64 ) ;
233- impl_dual_state_helmholtz_energy ! ( PyStateHDD , PyStateHDD , PyHyperDualDual64 , PyHyperDualDual64 , HyperDual <Dual64 , f64 >, PyDual64 ) ;
234- dual_number ! ( PyDualVec2 , PyDualVec2 , DualVec64 <2 >, f64 ) ;
220+ impl_dual_state_helmholtz_energy ! ( PyStateD2 , PyDual2_64 , Dual2_64 , f64 ) ;
221+ impl_dual_state_helmholtz_energy ! ( PyStateD3 , PyDual3_64 , Dual3_64 , f64 ) ;
222+ impl_dual_state_helmholtz_energy ! ( PyStateHDD , PyHyperDualDual64 , HyperDual <Dual64 , f64 >, PyDual64 ) ;
223+ dual_number ! ( PyDualVec2 , DualVec64 <2 >, f64 ) ;
235224impl_dual_state_helmholtz_energy ! (
236225 PyStateHDDVec2 ,
237- PyStateHDDVec2 ,
238- PyHyperDualVec2 ,
239226 PyHyperDualVec2 ,
240227 HyperDual <DualVec64 <2 >, f64 >,
241228 PyDualVec2
242229) ;
243230impl_dual_state_helmholtz_energy ! (
244- PyStateHDDVec3 ,
245231 PyStateHDDVec3 ,
246232 PyHyperDualVec3 ,
247- PyHyperDualVec3 ,
248233 HyperDual <DualVec64 <3 >, f64 >,
249234 PyDualVec3
250235) ;
251236impl_dual_state_helmholtz_energy ! (
252- PyStateD3D ,
253237 PyStateD3D ,
254238 PyDual3Dual64 ,
255- PyDual3Dual64 ,
256239 Dual3 <Dual64 , f64 >,
257240 PyDual64
258241) ;
259242impl_dual_state_helmholtz_energy ! (
260- PyStateD3DVec2 ,
261243 PyStateD3DVec2 ,
262244 PyDual3DualVec2 ,
263- PyDual3DualVec2 ,
264245 Dual3 <DualVec64 <2 >, f64 >,
265246 PyDualVec2
266247) ;
267248impl_dual_state_helmholtz_energy ! (
268249 PyStateD3DVec3 ,
269- PyStateD3DVec3 ,
270- PyDual3DualVec3 ,
271250 PyDual3DualVec3 ,
272251 Dual3 <DualVec64 <3 >, f64 >,
273252 PyDualVec3
0 commit comments