def mcfunc(self, model_parameters):
		
		no_samples = 1
		
		#experimental parameters
		T_service = 22. + 273.
		prec_stress = 0
		SS_stress = 750

		strain_stress, WTN = irreverisble.mechanics(prec_stress,SS_stress,T_service,model_parameters,no_samples)
		strain_stress = np.array(np.trim_zeros(strain_stress)).reshape(-1,2)
		#print strain_stress

		#----------------------------
		cal_val = []
		errors = []

		#traverses experimental data points
		for iexp, data in enumerate(exp[:,0]):
			
			#finding nearest neighbors that surround the data points, and using them to determine the error
			for ical, data in enumerate(strain_stress[:,0]):
				
				ical = ical-1 # May or may not be advantageous to keep this instead of the range attribute for mem save
				
				left_stresspoint = strain_stress[ical,0]
				right_stresspoint = strain_stress[ical+1,0]
				
				exp_datapoint = exp[iexp,0]
				
				# finding the two nearest stress points and interpolating stress and strain
				if(exp_datapoint>left_stresspoint and exp_datapoint<right_stresspoint):
									
					# stores the differences between the successive approximations so we interpolate
					left_difference = exp_datapoint-left_stresspoint
					right_difference = right_stresspoint-exp_datapoint
					
					total_difference = left_difference+right_difference
					
					left_weight = left_difference/total_difference
					right_weight = right_difference/total_difference
					  
					# interpolate strain based on stress
					interpolated_stress = left_weight*left_stresspoint + right_weight*right_stresspoint
					interpolated_strain = left_weight*strain_stress[ical,1] + right_weight*strain_stress[ical+1,1]
						
					strain_error = interpolated_strain - exp[iexp,1]    
					
					#adds value, we want to find difference between these approximated data points and the real results
					cal_val.append([interpolated_stress,interpolated_strain])                 
					errors.append(strain_error)
					
					break

		error_rms = self.error_evaluation_rms(errors)    
		cal_val = np.asarray(cal_val)

		return error_rms
	def irreversible_model(self, model_parameters, SS_stress):
		
		no_samples = 1
		
		#experimental parameters
		T_service = 22. + 273.
		prec_stress = 0

		strain_stress, WTN = irreverisble.mechanics(prec_stress,SS_stress,T_service,model_parameters,no_samples)
		return np.array(np.trim_zeros(strain_stress)).reshape(-1,2)
Exemple #3
0
    def irreversible_model(self, model_parameters, SS_stress):

        no_samples = 1

        #experimental parameters
        T_service = 22. + 273.
        prec_stress = 0

        strain_stress, WTN = irreverisble.mechanics(prec_stress, SS_stress,
                                                    T_service,
                                                    model_parameters,
                                                    no_samples)
        return np.array(np.trim_zeros(strain_stress)).reshape(-1, 2)
Exemple #4
0
    def mcfunc(self, model_parameters, SS_stress):

        no_samples = 1

        #experimental parameters
        #SS_stress = 1009.384532 # determined by material_analytics.py
        T_service = 22. + 273.
        prec_stress = 0

        strain_stress, WTN = irreverisble.mechanics(prec_stress, SS_stress,
                                                    T_service,
                                                    model_parameters,
                                                    no_samples)
        strain_stress = np.array(np.trim_zeros(strain_stress)).reshape(-1, 2)

        cal_val = []
        errors = []

        # this code, when uncommented, traverses all experimental data points and return their error
        #traverses experimental data points
        for iexp, data in enumerate(self.exp[:, 0]):

            #finding nearest neighbors that surround the data points, and using them to determine the error
            for ical, data in enumerate(strain_stress[:, 0]):

                ical = ical - 1  # May or may not be advantageous to keep this instead of the range attribute for mem save

                left_stresspoint = strain_stress[ical, 0]
                right_stresspoint = strain_stress[ical + 1, 0]

                exp_datapoint = self.exp[iexp, 0]

                # finding the two nearest stress points and interpolating stress and strain
                if (exp_datapoint > left_stresspoint
                        and exp_datapoint < right_stresspoint):

                    # stores the differences between the successive approximations so we interpolate
                    left_difference = exp_datapoint - left_stresspoint
                    right_difference = right_stresspoint - exp_datapoint

                    total_difference = left_difference + right_difference

                    left_weight = left_difference / total_difference
                    right_weight = right_difference / total_difference

                    # interpolate strain based on stress
                    interpolated_stress = left_weight * left_stresspoint + right_weight * right_stresspoint
                    interpolated_strain = left_weight * strain_stress[
                        ical, 1] + right_weight * strain_stress[ical + 1, 1]

                    strain_error = interpolated_strain - self.exp[iexp, 1]

                    #adds value, we want to find difference between these approximated data points and the real results
                    cal_val.append([interpolated_stress, interpolated_strain])
                    errors.append(strain_error)

                    break

        error_rms = self.error_evaluation_rms(errors)
        cal_val = np.asarray(cal_val)

        return error_rms