Coverage for yaptide/converter/converter/fluka/cards/compound_card.py: 61%

18 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-07-01 12:55 +0000

1from dataclasses import dataclass, field 

2from converter.fluka.cards.card import Card 

3from converter.fluka.helper_parsers.material_parser import FlukaCompound 

4 

5 

6@dataclass 

7class CompoundsCard: 

8 """ 

9 Class representing description of compound material in FLUKA input. 

10 Every compound assignment is represented by one or more lines if 

11 there are more than 3 components: 

12 codewd - "COMPOUND" 

13 what(1) - mass fraction of first material in the compound 

14 what(2) - name of first material 

15 what(3) - mass fraction of second material in the compound 

16 what(4) - name of second material 

17 what(5) - mass fraction of third material in the compound 

18 what(6) - name of third material 

19 sdum - name of the compound 

20 If there are more than 3 materials in the compound, another lines are added with same sdum 

21 documentation: https://flukafiles.web.cern.ch/manual/chapters/description_input/description_options/compound.html # skipcq: FLK-W505 

22 """ 

23 

24 data: list[FlukaCompound] = field(default_factory=list) 

25 codewd: str = "COMPOUND" 

26 

27 def __str__(self) -> str: 

28 """Return the card as a string.""" 

29 result = "" 

30 for compound in self.data: 

31 sdum = compound.fluka_name 

32 for i in range(0, len(compound.composition), 3): 

33 what = [] 

34 for content, material in compound.composition[i:i + 3]: 

35 what.append(content) 

36 what.append(material) 

37 result += str(Card(self.codewd, what, sdum)) + "\n" 

38 return result.strip()