TCAD lab 8 code - partial