Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

# -*- coding: utf-8 -*- 

'''Chemical Engineering Design Library (ChEDL). Utilities for process modeling. 

Copyright (C) 2017, Caleb Bell <Caleb.Andrew.Bell@gmail.com> 

 

Permission is hereby granted, free of charge, to any person obtaining a copy 

of this software and associated documentation files (the "Software"), to deal 

in the Software without restriction, including without limitation the rights 

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 

copies of the Software, and to permit persons to whom the Software is 

furnished to do so, subject to the following conditions: 

 

The above copyright notice and this permission notice shall be included in all 

copies or substantial portions of the Software. 

 

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 

SOFTWARE.''' 

 

from __future__ import division 

import types 

import numpy as np 

import fluids 

 

'''Basic module which wraps all fluids functions with numpy's vectorize. 

All other object - dicts, classes, etc - are not wrapped. Supports star  

imports; so the same objects exported when importing from the main library 

will be imported from here.  

 

>>> from fluids.vectorized import * 

 

Inputs do not need to be numpy arrays; they can be any interable: 

 

>>> fluids.vectorized.friction_factor(Re=[100, 1000, 10000], eD=0) 

array([ 0.64 , 0.064 , 0.03088295]) 

 

Note that because this needs to import fluids itself, fluids.vectorized 

needs to be imported separately; the following will cause an error: 

 

>>> import fluids 

>>> fluids.vectorized # Won't work, has not been imported yet 

 

The correct syntax is as follows: 

 

>>> import fluids.vectorized # Necessary 

>>> from fluids.vectorized import * # May be used without first importing fluids 

''' 

 

__all__ = [] 

 

for name in dir(fluids): 

obj = getattr(fluids, name) 

if isinstance(obj, types.FunctionType): 

obj = np.vectorize(obj) 

__all__.append(name) 

globals()[name] = obj