coefficients.py 851 B

123456789101112131415161718192021222324
  1. class coefficients:
  2. def __init__(self, diff, conv, flux, porder, nele):
  3. self.diffusion = diff
  4. self.covection = conv
  5. self.flux = flux
  6. self.porder = porder
  7. self.nele = nele
  8. @classmethod
  9. def from_input(cls):
  10. while True:
  11. try:
  12. print("Please provide the following coefficients.")
  13. diff = float(input("Diffusion coefficient: "))
  14. conv = float(input("Covection coefficient: "))
  15. flux = float(input("Flux: "))
  16. porder = int(input("Order of polynomials: "))
  17. nele = int(input("Number of elements: "))
  18. except ValueError:
  19. print("Sorry, wrong data type.")
  20. continue
  21. else:
  22. break
  23. return cls(diff, conv, flux, porder, nele)